ZQuest Classic Coverage Report


Directory: src/
File: src/zc/script_drawing.cpp
Date: 2025-10-22 06:47:12
Exec Total Coverage
Lines: 1489 5753 25.9%
Functions: 55 110 50.0%
Branches: 635 2962 21.4%

Line Branch Exec Source
1 //! ritate_sprite_trans doesn't seem to be supported by or allegro header !?
2
3 //glibc 2.28 and later require this: -Z
4 #include <optional>
5 #include <utility>
6 #ifdef __GNUG__
7 #define ALLEGRO_NO_FIX_ALIASES
8 #endif
9
10 #include "base/qrs.h"
11 #include "base/dmap.h"
12 #include "base/zdefs.h"
13 #include "base/zc_alleg.h"
14 #include "zc/script_drawing.h"
15 #include "zc/rendertarget.h"
16 #include "zc/maps.h"
17 #include "tiles.h"
18 #include "zc/zelda.h"
19 #include "zc/ffscript.h"
20 #include "base/util.h"
21 #include "subscr.h"
22 #include "drawing.h"
23 #include "base/mapscr.h"
24 #include "base/misctypes.h"
25 using namespace util;
26 extern refInfo *ri;
27 extern script_bitmaps scb;
28 #include <stdio.h>
29 #include <fstream>
30
31 #define DegtoFix(d) ((d)*0.7111111111111)
32 #define RadtoFix(d) ((d)*40.743665431525)
33
34 static int32_t secondary_draw_origin_xoff;
35 static int32_t secondary_draw_origin_yoff;
36
37 124965634 static std::optional<std::pair<int, int>> get_draw_origin_offset(DrawOrigin draw_origin, int draw_origin_target_uid, int xoff, int yoff)
38 {
39 int xoffset;
40 int yoffset;
41
2/2
✓ Branch 0 taken 41428 times.
✓ Branch 1 taken 124924206 times.
124965634 if (draw_origin == DrawOrigin::Region)
42 {
43 41428 xoffset = xoff - viewport.x;
44 41428 yoffset = yoff - viewport.y;
45 41428 }
46
2/2
✓ Branch 0 taken 8072 times.
✓ Branch 1 taken 124916134 times.
124924206 else if (draw_origin == DrawOrigin::RegionScrollingNew)
47 {
48 8072 xoffset = xoff + FFCore.ScrollingData[SCROLLDATA_NRX];
49 8072 yoffset = yoff + FFCore.ScrollingData[SCROLLDATA_NRY];
50 8072 }
51
2/2
✓ Branch 0 taken 105313250 times.
✓ Branch 1 taken 19602884 times.
124916134 else if (draw_origin == DrawOrigin::PlayingField)
52 {
53 105313250 xoffset = xoff;
54 105313250 yoffset = yoff;
55 105313250 }
56
2/2
✓ Branch 0 taken 19596773 times.
✓ Branch 1 taken 6111 times.
19602884 else if (draw_origin == DrawOrigin::Screen)
57 {
58 19596773 xoffset = 0;
59 19596773 yoffset = 0;
60 19596773 }
61
1/2
✓ Branch 0 taken 6111 times.
✗ Branch 1 not taken.
6111 else if (draw_origin == DrawOrigin::Sprite)
62 {
63 6111 sprite* draw_origin_target = sprite::getByUID(draw_origin_target_uid);
64
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6111 times.
6111 if (!draw_origin_target)
65 {
66 Z_scripterrlog("Warning: Ignoring draw command using DRAW_ORIGIN_SPRITE with non-existent sprite uid: %d.\n", draw_origin_target_uid);
67 return std::nullopt;
68 }
69
70 6111 xoffset = xoff - viewport.x + draw_origin_target->x.getInt();
71 6111 yoffset = yoff - viewport.y + draw_origin_target->y.getInt();
72 6111 }
73 else
74 {
75 // Unexpected.
76 xoffset = 0;
77 yoffset = 0;
78 }
79
80 124965634 return std::make_pair(xoffset, yoffset);
81 124965634 }
82
83 23279041 std::pair<int, bool> resolveScriptingBitmapId(int scripting_bitmap_id)
84 {
85
4/6
✓ Branch 0 taken 3396548 times.
✓ Branch 1 taken 19882493 times.
✓ Branch 2 taken 3396548 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3396548 times.
✗ Branch 5 not taken.
23279041 if ((scripting_bitmap_id % 10000 == 0) && (scripting_bitmap_id >= -20000 && scripting_bitmap_id <= 60000))
86 {
87 // Handles zscript values for RT_SCREEN, RT_BITMAP0, etc.
88 3396548 return {scripting_bitmap_id / 10000, false};
89 }
90
3/4
✓ Branch 0 taken 19882493 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11739102 times.
✓ Branch 3 taken 8143391 times.
19882493 else if (scripting_bitmap_id - 10 >= -2 && scripting_bitmap_id - 10 <= rtBMP6)
91 {
92 // Handles Game->LoadBitmapID, which sets the bitmap pointer as a "long" int.
93 8143391 return {scripting_bitmap_id - 10, false};
94 }
95 else
96 {
97 // This is a user bitmap.
98 11739102 return {scripting_bitmap_id, true};
99 }
100 23279041 }
101
102 static BITMAP* current_target_bmp;
103
104 66997310 static BITMAP* resolveScriptingBitmap(int scripting_bitmap_id)
105 {
106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66997310 times.
66997310 if (scripting_bitmap_id < 0)
107 {
108 // Handles zscript values for RT_SCREEN, etc.
109 return FFCore.GetScriptBitmap((scripting_bitmap_id / 10000) + 10, current_target_bmp);
110 }
111 else
112 {
113 // Handles Game->LoadBitmapID, which sets the bitmap pointer as a "long" int.
114 // Also handles user bitmaps.
115 66997310 return FFCore.GetScriptBitmap(scripting_bitmap_id, current_target_bmp);
116 }
117 66997310 }
118
119 inline double sd_log2( double n )
120 {
121 // log(n)/log(2) is log2.
122 double v = log( (double)n ) / log( (double)2 );
123 return v;
124 }
125
126 inline bool isPowerOfTwo(int32_t n)
127 {
128 if(n==0)
129 return false;
130
131 return (ceil(sd_log2(n)) == floor(sd_log2(n)));
132 }
133
134
135
136 template<class T> inline
137 263255 fixed degrees_to_fixed(T d)
138 {
139 263255 return ftofix(DegtoFix(d));
140 }
141 template<class T> inline
142 fixed radians_to_fixed(T d)
143 {
144 return ftofix(RadtoFix(d));
145 }
146
147 BITMAP* ScriptDrawingBitmapPool::_parent_bmp = 0;
148
149 class TileHelper
150 {
151 public:
152
153 46094 static void OldPutTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
154 {
155 // Past the end of the tile page?
156
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46094 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46094 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
157 {
158 byte w2=(tile+w)%TILES_PER_ROW;
159 OldPutTile(_Dest, tile, x, y, w-w2, h, color, flip);
160 OldPutTile(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip);
161 return;
162 }
163
164
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 46094 times.
46094 switch(flip)
165 {
166 case 1:
167 for(int32_t j=0; j<h; j++)
168 for(int32_t k=w-1; k>=0; k--)
169 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip);
170
171 break;
172
173 case 2:
174 for(int32_t j=h-1; j>=0; j--)
175 for(int32_t k=0; k<w; k++)
176 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip);
177
178 break;
179
180 case 3:
181 for(int32_t j=h-1; j>=0; j--)
182 for(int32_t k=w-1; k>=0; k--)
183 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip);
184
185 break;
186
187 46094 case 0:
188 default:
189
2/2
✓ Branch 0 taken 181240 times.
✓ Branch 1 taken 46094 times.
227334 for(int32_t j=0; j<h; j++)
190
2/2
✓ Branch 0 taken 1111148 times.
✓ Branch 1 taken 181240 times.
1292388 for(int32_t k=0; k<w; k++)
191 1292388 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip);
192
193 46094 break;
194 }
195 46094 }
196
197 4793520 static void OverTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
198 {
199 4793520 overtileblock16(_Dest,tile,x,y,w,h,color,flip,skiprows);
200 4793520 }
201
202 static void OverTileCloaked(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t flip, byte skiprows=0)
203 {
204 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
205 {
206 byte w2=(tile+w)%TILES_PER_ROW;
207 OverTileCloaked(_Dest, tile, x, y, w-w2, h, flip);
208 OverTileCloaked(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, flip);
209 return;
210 }
211
212 switch(flip)
213 {
214 case 1:
215 for(int32_t j=0; j<h; j++)
216 for(int32_t k=w-1; k>=0; k--)
217 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, flip);
218
219 break;
220
221 case 2:
222 for(int32_t j=h-1; j>=0; j--)
223 for(int32_t k=0; k<w; k++)
224 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, flip);
225
226 break;
227
228 case 3:
229 for(int32_t j=h-1; j>=0; j--)
230 for(int32_t k=w-1; k>=0; k--)
231 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, flip);
232
233 break;
234
235 default:
236 for(int32_t j=0; j<h; j++)
237 for(int32_t k=0; k<w; k++)
238 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, flip);
239
240 break;
241 }
242 }
243
244 289390 static void OverTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
245 {
246
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 289390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
289390 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
247 {
248 byte w2=(tile+w)%TILES_PER_ROW;
249 OverTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
250 OverTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
251 return;
252 }
253
254
1/4
✓ Branch 0 taken 289390 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
289390 switch(flip)
255 {
256 case 1:
257 for(int32_t j=0; j<h; j++)
258 for(int32_t k=w-1; k>=0; k--)
259 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
260
261 break;
262
263 case 2:
264 for(int32_t j=h-1; j>=0; j--)
265 for(int32_t k=0; k<w; k++)
266 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
267
268 break;
269
270 case 3:
271 for(int32_t j=h-1; j>=0; j--)
272 for(int32_t k=w-1; k>=0; k--)
273 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
274
275 break;
276
277 default:
278
2/2
✓ Branch 0 taken 1672950 times.
✓ Branch 1 taken 289390 times.
1962340 for(int32_t j=0; j<h; j++)
279
2/2
✓ Branch 0 taken 23552575 times.
✓ Branch 1 taken 1672950 times.
25225525 for(int32_t k=0; k<w; k++)
280 25225525 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
281
282 289390 break;
283 }
284 289390 }
285
286 static void PutTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
287 {
288 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
289 {
290 byte w2=(tile+w)%TILES_PER_ROW;
291 PutTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
292 PutTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
293 return;
294 }
295
296 switch(flip)
297 {
298 case 1:
299 for(int32_t j=0; j<h; j++)
300 for(int32_t k=w-1; k>=0; k--)
301 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
302
303 break;
304
305 case 2:
306 for(int32_t j=h-1; j>=0; j--)
307 for(int32_t k=0; k<w; k++)
308 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
309
310 break;
311
312 case 3:
313 for(int32_t j=h-1; j>=0; j--)
314 for(int32_t k=w-1; k>=0; k--)
315 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
316
317 break;
318
319 default:
320 for(int32_t j=0; j<h; j++)
321 for(int32_t k=0; k<w; k++)
322 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
323
324 break;
325 }
326 }
327 };
328
329
330
331
332 3343769 void do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
333 {
334 //sdci[1]=layer
335 //sdci[2]=x
336 //sdci[3]=y
337 //sdci[4]=x2
338 //sdci[5]=y2
339 //sdci[6]=color
340 //sdci[7]=scale factor
341 //sdci[8]=rotation anchor x
342 //sdci[9]=rotation anchor y
343 //sdci[10]=rotation angle
344 //sdci[11]=fill
345 //sdci[12]=opacity
346
1/2
✓ Branch 0 taken 3343769 times.
✗ Branch 1 not taken.
3343769 if(sdci[7]==0) //scale
347 {
348 return;
349 }
350
351 3343769 int32_t x1=sdci[2]/10000;
352 3343769 int32_t y1=sdci[3]/10000;
353 3343769 int32_t x2=sdci[4]/10000;
354 3343769 int32_t y2=sdci[5]/10000;
355
356
1/2
✓ Branch 0 taken 3343769 times.
✗ Branch 1 not taken.
3343769 if(x1>x2)
357 {
358 zc_swap(x1,x2);
359 }
360
361
2/2
✓ Branch 0 taken 3324253 times.
✓ Branch 1 taken 19516 times.
3343769 if(y1>y2)
362 {
363 19516 zc_swap(y1,y2);
364 19516 }
365
366
2/2
✓ Branch 0 taken 3342035 times.
✓ Branch 1 taken 1734 times.
3343769 if(sdci[7] != 10000)
367 {
368 1734 int32_t w=x2-x1+1;
369 1734 int32_t h=y2-y1+1;
370 1734 int32_t w2=(w*sdci[7])/10000;
371 1734 int32_t h2=(h*sdci[7])/10000;
372 1734 x1=x1-((w2-w)/2);
373 1734 x2=x2+((w2-w)/2);
374 1734 y1=y1-((h2-h)/2);
375 1734 y2=y2+((h2-h)/2);
376 1734 }
377
378 3343769 int32_t color=sdci[6]/10000;
379
380
2/2
✓ Branch 0 taken 3306923 times.
✓ Branch 1 taken 36846 times.
3343769 if(sdci[12]/10000<=127) //translucent
381 {
382 36846 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
383 36846 }
384
385
2/2
✓ Branch 0 taken 82060 times.
✓ Branch 1 taken 3261709 times.
3343769 if(sdci[10]==0) //no rotation
386 {
387
2/2
✓ Branch 0 taken 838727 times.
✓ Branch 1 taken 2422982 times.
3261709 if(sdci[11]) //filled
388 {
389 2422982 rectfill(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
390 2422982 }
391 else //outline
392 {
393 838727 rect(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
394 }
395 3261709 }
396 else //rotate
397 {
398 int32_t xy[16];
399 82060 int32_t rx=sdci[8]/10000;
400 82060 int32_t ry=sdci[9]/10000;
401 82060 fixed ra1=itofix(sdci[10]%10000)/10000;
402 82060 fixed ra2=itofix(sdci[10]/10000);
403 82060 fixed ra=ra1+ra2;
404 82060 ra = (ra/360)*256;
405
406 82060 fixed fcosa = fixcos(ra);
407 82060 fixed fsina = fixsin(ra);
408
409 82060 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
410 82060 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
411 82060 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
412 82060 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
413 82060 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
414 82060 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
415 82060 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
416 82060 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
417 82060 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
418 82060 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
419 82060 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
420 82060 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
421 82060 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
422 82060 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
423 82060 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
424 82060 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
425
426
1/2
✓ Branch 0 taken 82060 times.
✗ Branch 1 not taken.
82060 if(sdci[11]) //filled
427 {
428 82060 polygon(bmp, 4, xy, color);
429 82060 }
430 else //outline
431 {
432 line(bmp, xy[0], xy[1], xy[10], xy[11], color);
433 line(bmp, xy[2], xy[3], xy[12], xy[13], color);
434 line(bmp, xy[4], xy[5], xy[14], xy[15], color);
435 line(bmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
436 }
437 }
438
439 3343769 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
440 3343769 }
441
442 void do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
443 {
444 //sdci[1]=layer
445 //sdci[2]=x
446 //sdci[3]=y
447 //sdci[4]=tile
448 //sdci[5]=cset
449 //sdci[6]=width
450 //sdci[7]=height
451 //sdci[8]=overlay
452 //sdci[9]=opacity
453
454 int32_t x=sdci[2]/10000;
455 int32_t y=sdci[3]/10000;
456
457 int32_t tile=sdci[4]/10000;
458 int32_t cs=sdci[5]/10000;
459 int32_t w=sdci[6]/10000;
460 int32_t h=sdci[7]/10000;
461 bool overlay=sdci[8];
462 bool trans=(sdci[9]/10000<=127);
463
464 frame2x2(bmp, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
465 }
466
467
468
469 1170681 void do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
470 {
471 //sdci[1]=layer
472 //sdci[2]=x
473 //sdci[3]=y
474 //sdci[4]=radius
475 //sdci[5]=color
476 //sdci[6]=scale factor
477 //sdci[7]=rotation anchor x
478 //sdci[8]=rotation anchor y
479 //sdci[9]=rotation angle
480 //sdci[10]=fill
481 //sdci[11]=opacity
482
1/2
✓ Branch 0 taken 1170681 times.
✗ Branch 1 not taken.
1170681 if(sdci[6]==0) //scale
483 {
484 return;
485 }
486
487 1170681 int32_t x1=sdci[2]/10000;
488 1170681 int32_t y1=sdci[3]/10000;
489 1170681 qword r=sdci[4];
490
491
1/2
✓ Branch 0 taken 1170681 times.
✗ Branch 1 not taken.
1170681 if(sdci[6] != 10000)
492 {
493 r*=sdci[6];
494 r/=10000;
495 }
496
497 1170681 r/=10000;
498 1170681 int32_t color=sdci[5]/10000;
499
500
2/2
✓ Branch 0 taken 989374 times.
✓ Branch 1 taken 181307 times.
1170681 if(sdci[11]/10000<=127) //translucent
501 {
502 181307 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
503 181307 }
504
505
5/6
✓ Branch 0 taken 58575 times.
✓ Branch 1 taken 1112106 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 57231 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1344 times.
1170681 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
506 {
507 int32_t xy[2];
508 57231 int32_t rx=sdci[7]/10000;
509 57231 int32_t ry=sdci[8]/10000;
510 57231 fixed ra1=itofix(sdci[9]%10000)/10000;
511 57231 fixed ra2=itofix(sdci[9]/10000);
512 57231 fixed ra=ra1+ra2;
513 57231 ra = (ra/360)*256;
514
515 57231 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
516 57231 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
517 57231 x1=xy[0];
518 57231 y1=xy[1];
519 57231 }
520
521
2/2
✓ Branch 0 taken 1153667 times.
✓ Branch 1 taken 17014 times.
1170681 if(sdci[10]) //filled
522 {
523 1153667 circlefill(bmp, x1+xoffset, y1+yoffset, r, color);
524 1153667 }
525 else //outline
526 {
527 17014 circle(bmp, x1+xoffset, y1+yoffset, r, color);
528 }
529
530 1170681 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
531 1170681 }
532
533
534 void do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
535 {
536 //sdci[1]=layer
537 //sdci[2]=x
538 //sdci[3]=y
539 //sdci[4]=radius
540 //sdci[5]=start angle
541 //sdci[6]=end angle
542 //sdci[7]=color
543 //sdci[8]=scale factor
544 //sdci[9]=rotation anchor x
545 //sdci[10]=rotation anchor y
546 //sdci[11]=rotation angle
547 //sdci[12]=closed
548 //sdci[13]=fill
549 //sdci[14]=opacity
550
551 if(sdci[8]==0) //scale
552 {
553 return;
554 }
555
556 int32_t cx=sdci[2]/10000;
557 int32_t cy=sdci[3]/10000;
558 qword r=sdci[4];
559
560 if(sdci[8] != 10000)
561 {
562 r*=sdci[8];
563 r/=10000;
564 }
565
566 r/=10000;
567
568 int32_t color=sdci[7]/10000;
569
570 fixed ra1=itofix(sdci[11]%10000)/10000;
571 fixed ra2=itofix(sdci[11]/10000);
572 fixed ra=ra1+ra2;
573 ra = (ra/360)*256;
574
575
576 fixed a1=itofix(sdci[5]%10000)/10000;
577 fixed a2=itofix(sdci[5]/10000);
578 fixed sa=a1+a2;
579 sa = (sa/360)*256;
580
581 a1=itofix(sdci[6]%10000)/10000;
582 a2=itofix(sdci[6]/10000);
583 fixed ea=a1+a2;
584 ea = (ea/360)*256;
585
586 if(sdci[11]!=0) //rotation
587 {
588 int32_t rx=sdci[9]/10000;
589 int32_t ry=sdci[10]/10000;
590
591 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
592 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
593 ea-=ra;
594 sa-=ra;
595 }
596
597 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
598 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
599
600 if(sdci[12]) //closed
601 {
602 if(sdci[13]) //filled
603 {
604 clear_bitmap(prim_bmp);
605 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
606 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
607 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
608 int fillx = zc_max(0,fx)+xoffset;
609 int filly = zc_max(0,fy)+yoffset;
610 zprint2("Screen->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
611 floodfill(prim_bmp, fillx, filly, color);
612
613 if(sdci[14]/10000<=127) //translucent
614 {
615 draw_trans_sprite(bmp, prim_bmp, 0,0);
616 }
617 else
618 {
619 draw_sprite(bmp, prim_bmp, 0,0);
620 }
621 }
622 else
623 {
624 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
625 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
626 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
627 }
628 }
629 else
630 {
631 if(sdci[14]/10000<=127) //translucent
632 {
633 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
634 }
635
636 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
637 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
638 }
639 }
640
641
642 1850 void do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
643 {
644 //sdci[1]=layer
645 //sdci[2]=x
646 //sdci[3]=y
647 //sdci[4]=radiusx
648 //sdci[5]=radiusy
649 //sdci[6]=color
650 //sdci[7]=scale factor
651 //sdci[8]=rotation anchor x
652 //sdci[9]=rotation anchor y
653 //sdci[10]=rotation angle
654 //sdci[11]=fill
655 //sdci[12]=opacity
656
657
1/2
✓ Branch 0 taken 1850 times.
✗ Branch 1 not taken.
1850 if(sdci[7]==0) //scale
658 {
659 return;
660 }
661
662 1850 int32_t x1=sdci[2]/10000;
663 1850 int32_t y1=sdci[3]/10000;
664 1850 int32_t radx=sdci[4]/10000;
665 1850 radx*=sdci[7]/10000;
666 1850 int32_t rady=sdci[5]/10000;
667 1850 rady*=sdci[7]/10000;
668 1850 int32_t color=sdci[6]/10000;
669 1850 float rotation = sdci[10]/10000;
670
671 1850 int32_t rx=sdci[8]/10000;
672 1850 int32_t ry=sdci[9]/10000;
673 1850 fixed ra1=itofix(sdci[10]%10000)/10000;
674 1850 fixed ra2=itofix(sdci[10]/10000);
675 1850 fixed ra=ra1+ra2;
676 1850 ra = (ra/360)*256;
677
678 int32_t xy[2];
679 1850 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
680 1850 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
681 1850 x1=xy[0];
682 1850 y1=xy[1];
683
684
6/8
✓ Branch 0 taken 1746 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 1687 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 1687 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1687 times.
1850 if(radx<1||rady<1||radx>255||rady>255) return;
685
686 1687 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
687
688
2/2
✓ Branch 0 taken 1630 times.
✓ Branch 1 taken 57 times.
1687 if(sdci[11]) //filled
689 {
690
691
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 606 times.
1630 if(sdci[12]/10000<128) //translucent
692 {
693 1024 clear_bitmap(prim_bmp);
694
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
695 1024 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
696 1024 draw_trans_sprite(bmp, prim_bmp, 0, 0);
697 1024 }
698 else // no opacity
699 {
700
1/2
✓ Branch 0 taken 606 times.
✗ Branch 1 not taken.
606 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
701 606 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
702 }
703 1630 }
704 else //not filled
705 {
706
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 43 times.
57 if(sdci[12]/10000<128) //translucent
707 {
708 14 clear_bitmap(prim_bmp);
709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
710 14 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
711 14 draw_trans_sprite(bmp, prim_bmp, 0, 0);
712 14 }
713 else // no opacity
714 {
715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
716 43 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
717 }
718 }
719
720 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
721 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
722 // the ellipse, but it shouldn't be used anyway.
723
1/2
✓ Branch 0 taken 1687 times.
✗ Branch 1 not taken.
1687 if(color==0)
724 {
725 // This is very slow, so check the smallest possible square
726 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
727 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
728
729 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
730 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
731 if(getpixel(bmp, x, y)==255)
732 putpixel(bmp, x, y, 0);
733 }
734
735 1687 script_drawing_commands.ReleaseSubBitmap(bitty);
736 1850 }
737
738
739 2351475 void do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
740 {
741 //sdci[1]=layer
742 //sdci[2]=x
743 //sdci[3]=y
744 //sdci[4]=x2
745 //sdci[5]=y2
746 //sdci[6]=color
747 //sdci[7]=scale factor
748 //sdci[8]=rotation anchor x
749 //sdci[9]=rotation anchor y
750 //sdci[10]=rotation angle
751 //sdci[11]=opacity
752
1/2
✓ Branch 0 taken 2351475 times.
✗ Branch 1 not taken.
2351475 if(sdci[7]==0) //scale
753 {
754 return;
755 }
756
757 2351475 int32_t x1=sdci[2]/10000;
758 2351475 int32_t y1=sdci[3]/10000;
759 2351475 int32_t x2=sdci[4]/10000;
760 2351475 int32_t y2=sdci[5]/10000;
761
762
2/2
✓ Branch 0 taken 1903153 times.
✓ Branch 1 taken 448322 times.
2351475 if(sdci[7] != 10000)
763 {
764 448322 int32_t w=x2-x1+1;
765 448322 int32_t h=y2-y1+1;
766 448322 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
767 448322 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
768 448322 x1=x1-((w2-w)/2);
769 448322 x2=x2+((w2-w)/2);
770 448322 y1=y1-((h2-h)/2);
771 448322 y2=y2+((h2-h)/2);
772 448322 }
773
774 2351475 int32_t color=sdci[6]/10000;
775
776
1/2
✓ Branch 0 taken 2351475 times.
✗ Branch 1 not taken.
2351475 if(sdci[11]/10000<=127) //translucent
777 {
778 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
779 }
780
781
2/2
✓ Branch 0 taken 939459 times.
✓ Branch 1 taken 1412016 times.
2351475 if(sdci[10]!=0) //rotation
782 {
783 int32_t xy[4];
784 1412016 int32_t rx=sdci[8]/10000;
785 1412016 int32_t ry=sdci[9]/10000;
786 1412016 fixed ra1=itofix(sdci[10]%10000)/10000;
787 1412016 fixed ra2=itofix(sdci[10]/10000);
788 1412016 fixed ra=ra1+ra2;
789
790 1412016 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
791 1412016 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
792 1412016 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
793 1412016 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
794 1412016 x1=xy[0];
795 1412016 y1=xy[1];
796 1412016 x2=xy[2];
797 1412016 y2=xy[3];
798 1412016 }
799
800 2351475 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
801 2351475 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
802 2351475 }
803
804 void do_linesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
805 {
806 //sdci[1]=layer
807 //sdci[2]=array[10] = { x, y, x2, y2, colour, scale, rx, ry, angle, opacity }
808
809 //sdci[2]=x
810 //sdci[3]=y
811 //sdci[4]=x2
812 //sdci[5]=y2
813 //sdci[6]=color
814 //sdci[7]=scale factor
815 //sdci[8]=rotation anchor x
816 //sdci[9]=rotation anchor y
817 //sdci[10]=rotation angle
818 //sdci[11]=opacity
819 //if(sdci[7]==0) //scale
820 //{
821 // return;
822 //}
823
824 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
825
826 if(!v_ptr)
827 {
828 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
829 return;
830 }
831
832 std::vector<int32_t> &v = *v_ptr;
833
834 if(v.empty())
835 return;
836
837 int32_t* pos = &v[0];
838 int32_t sz = v.size();
839
840 for ( int32_t q = 0; q < sz; q+=10 )
841 {
842
843 int32_t x1 = v.at(q);
844 //Z_scripterrlog("Lines( x1 ) is: %d\n", x1);
845 int32_t y1 = v.at(q+1);
846 //Z_scripterrlog("Lines( x2 ) is: %d\n", y1);
847 int32_t x2 = v.at(q+2);
848 //Z_scripterrlog("Lines( x2 ) is: %d\n", x2);
849 int32_t y2 = v.at(q+3);
850 //Z_scripterrlog("Lines( y2 ) is: %d\n", y2);
851 int32_t color = v.at(q+4);
852 //Z_scripterrlog("Lines( colour ) is: %d\n", color);
853 //Z_scripterrlog("Lines( scale ) is: %d\n", v.at(q+5));
854 if (v.at(q+5) == 0) { Z_scripterrlog("Lines() aborting due to scale\n"); return; }//scale
855
856 if( v.at(q+5) != 10000)
857 {
858 int32_t w=x2-x1+1;
859 int32_t h=y2-y1+1;
860 int32_t w2=int32_t(w*((double)v.at(q+5)));
861 int32_t h2=int32_t(h*((double)v.at(q+5)));
862 x1=x1-((w2-w)/2);
863 x2=x2+((w2-w)/2);
864 y1=y1-((h2-h)/2);
865 y2=y2+((h2-h)/2);
866 }
867
868
869 //Z_scripterrlog("Lines( opacity ) is: %d\n", v.at(q+9));
870 if(v.at(q+9) <= 127) //translucent
871 {
872 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
873 }
874 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
875 //Z_scripterrlog("Lines( rotation ) is: %d\n", v.at(q+8));
876 //Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+6));
877 //Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+7));
878 if( v.at(q+8) !=0 ) //rotation
879 {
880 int32_t xy[4];
881
882 int32_t rx = v.at(q+6);
883
884 int32_t ry = v.at(q+7);
885
886 fixed ra1=itofix(v.at(q+8) % 1);
887 fixed ra2=itofix(v.at(q+8));
888 fixed ra=ra1+ra2;
889
890 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
891 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
892 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
893 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
894 x1=xy[0];
895 y1=xy[1];
896 x2=xy[2];
897 y2=xy[3];
898 }
899 //Z_scripterrlog("Lines( xofs ) is: %d\n", xoffset);
900 //Z_scripterrlog("Lines( yofs ) is: %d\n", yoffset);
901 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
902 }
903 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
904 }
905
906 1080 void do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
907 {
908 //sdci[1]=layer
909 //sdci[2]=point count
910 //sdci[3]array[]
911 //sdci[4] = colour
912 //sdci[5] = opacity
913
914 1080 int32_t col = sdci[4]/10000;
915 1080 int32_t op = sdci[5]/10000;
916
917 1080 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
918
919
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(!v_ptr)
920 {
921 al_trace("Screen->Polygon: Vector pointer is null! Internal error. \n");
922 return;
923 }
924
925 1080 std::vector<int32_t> &v = *v_ptr;
926
927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1080 times.
1080 if(v.empty())
928 return;
929
930 1080 int32_t* pos = &v[0];
931 1080 int32_t sz = v.size();
932 1080 int32_t numpoints = (sdci[2]/10000);
933
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(sz & 1) --sz; //even amount only
934
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(numpoints > sz/2) //cap to array
935 numpoints = sz/2;
936
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(numpoints < 1)
937 return; //Don't draw 0 or negative point count
938
939
2/2
✓ Branch 0 taken 6480 times.
✓ Branch 1 taken 1080 times.
7560 for (int32_t i = 0; i < sz; i += 2)
940 {
941 6480 pos[i] += xoffset;
942 6480 pos[i + 1] += yoffset;
943 6480 }
944
945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1080 times.
1080 if(op <= 127) //translucent
946 {
947 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
948 }
949 1080 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
950
951 1080 polygon(bmp, numpoints, (int32_t*)pos, col);
952 1080 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
953 1080 }
954
955 void bmp_do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
956 {
957 //sdci[1]=layer
958 //sdci[2]=point count
959 //sdci[3]array[]
960 //sdci[4] = colour
961 //sdci[5] = opacity
962
963 int32_t col = sdci[4]/10000;
964 int32_t op = sdci[5]/10000;
965
966 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
967 {
968 Z_scripterrlog("bitmap->Polygon() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
969 return;
970 }
971 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
972 if ( refbmp == NULL ) return;
973
974 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
975
976 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
977
978 if(!v_ptr)
979 {
980 al_trace("bitmap->Polygon: Vector pointer is null! Internal error. \n");
981 return;
982 }
983
984 std::vector<int32_t> &v = *v_ptr;
985
986 if(v.empty())
987 return;
988
989 int32_t* pos = &v[0];
990 int32_t sz = v.size();
991 int32_t numpoints = (sdci[2]/10000);
992 if(sz & 1) --sz; //even amount only
993 if(numpoints > sz/2) //cap to array
994 numpoints = sz/2;
995 if(numpoints < 1)
996 return; //Don't draw 0 or negative point count
997
998 for (int32_t i = 0; i < sz; i += 2)
999 {
1000 pos[i] += xoffset;
1001 pos[i + 1] += yoffset;
1002 }
1003
1004 if(op <= 127) //translucent
1005 {
1006 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1007 }
1008 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1009
1010 polygon(refbmp, numpoints, (int32_t*)pos, col);
1011 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1012 }
1013
1014 void do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1015 {
1016 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
1017
1018 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
1019 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
1020 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
1021 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
1022 };
1023
1024 if(sdci[11]/10000 < 128) //translucent
1025 {
1026 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1027 }
1028
1029 spline(bmp, points, sdci[10]/10000);
1030
1031 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1032 }
1033
1034
1035 404879 void do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1036 {
1037 //sdci[1]=layer
1038 //sdci[2]=x
1039 //sdci[3]=y
1040 //sdci[4]=color
1041 //sdci[5]=rotation anchor x
1042 //sdci[6]=rotation anchor y
1043 //sdci[7]=rotation angle
1044 //sdci[8]=opacity
1045 404879 int32_t x1=sdci[2]/10000;
1046 404879 int32_t y1=sdci[3]/10000;
1047 404879 int32_t color=sdci[4]/10000;
1048
1049
2/2
✓ Branch 0 taken 404863 times.
✓ Branch 1 taken 16 times.
404879 if(sdci[8]/10000<=127) //translucent
1050 {
1051 16 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1052 16 }
1053
1054
1/2
✓ Branch 0 taken 404879 times.
✗ Branch 1 not taken.
404879 if(sdci[7]!=0) //rotation
1055 {
1056 int32_t xy[2];
1057 int32_t rx=sdci[5]/10000;
1058 int32_t ry=sdci[6]/10000;
1059 fixed ra1=itofix(sdci[7]%10000)/10000;
1060 fixed ra2=itofix(sdci[7]/10000);
1061 fixed ra=ra1+ra2;
1062
1063 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1064 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1065 x1=xy[0];
1066 y1=xy[1];
1067 }
1068
1069 404879 putpixel(bmp, x1+xoffset, y1+yoffset, color);
1070 404879 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1071 404879 }
1072
1073 void do_putpixelsr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1074 {
1075 //Z_scripterrlog("Starting putpixels()%s\n");
1076 //sdci[1]=layer
1077 //sdci[2]=array {x,y,colour,opacity}
1078 //sdci[3]=rotation anchor x
1079 //sdci[4]=rotation anchor y
1080 //sdci[5]=rotation angle
1081
1082
1083 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1084
1085 if(!v_ptr)
1086 {
1087 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1088 return;
1089 }
1090
1091 std::vector<int32_t> &v = *v_ptr;
1092
1093 if(v.empty())
1094 return;
1095
1096 int32_t* pos = &v[0];
1097 int32_t sz = v.size();
1098
1099
1100 int32_t x1 = 0;
1101 int32_t y1 = 0;
1102
1103 for ( int32_t q = 0; q < sz; q+=4 )
1104 {
1105 x1 = v.at(q); //pos[q];
1106 y1 = v.at(q+1); //pos[q+1];
1107 if(sdci[5]!=0) //rotation
1108 {
1109 int32_t xy[2];
1110 int32_t rx=sdci[3]/10000;
1111 int32_t ry=sdci[4]/10000;
1112 fixed ra1=itofix(sdci[5]%10000)/10000;
1113 fixed ra2=itofix(sdci[5]/10000);
1114 fixed ra=ra1+ra2;
1115
1116 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1117 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1118 x1=xy[0];
1119 y1=xy[1];
1120 }
1121 if ( v.at(q+3) /*pos[q+3]*/ < 128 ) drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1122 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1123 putpixel(bmp, x1+xoffset, y1+yoffset, v.at(q+2) /*pos[q+2]*/);
1124 }
1125 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1126 }
1127
1128 2302534 void do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1129 {
1130 //sdci[1]=layer
1131 //sdci[2]=x
1132 //sdci[3]=y
1133 //sdci[4]=tile
1134 //sdci[5]=tile width
1135 //sdci[6]=tile height
1136 //sdci[7]=color (cset)
1137 //sdci[8]=scale x
1138 //sdci[9]=scale y
1139 //sdci[10]=rotation anchor x
1140 //sdci[11]=rotation anchor y
1141 //sdci[12]=rotation angle
1142 //sdci[13]=flip
1143 //sdci[14]=transparency
1144 //sdci[15]=opacity
1145
1146 2302534 int32_t w = sdci[5]/10000;
1147 2302534 int32_t h = sdci[6]/10000;
1148
1149
4/8
✓ Branch 0 taken 2302534 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2302534 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2302534 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2302534 times.
2302534 if(w < 1 || h < 1 || h > 20 || w > 20)
1150 {
1151 return;
1152 }
1153
1154 2302534 int32_t xscale=sdci[8]/10000;
1155 2302534 int32_t yscale=sdci[9]/10000;
1156 2302534 int32_t rx = sdci[10]/10000;
1157 2302534 int32_t ry = sdci[11]/10000;
1158 2302534 float rotation=sdci[12]/10000;
1159 2302534 int32_t flip=(sdci[13]/10000)&3;
1160 2302534 bool transparency=sdci[14]!=0;
1161 2302534 int32_t opacity=sdci[15]/10000;
1162 2302534 int32_t color=sdci[7]/10000;
1163
1164 2302534 int32_t x1=sdci[2]/10000;
1165 2302534 int32_t y1=sdci[3]/10000;
1166
1167 //don't scale if it's not safe to do so
1168 2302534 bool canscale = true;
1169
1170
3/4
✓ Branch 0 taken 2281889 times.
✓ Branch 1 taken 20645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2281889 times.
2302534 if(xscale==0||yscale==0)
1171 {
1172 20645 return;
1173 }
1174
1175
3/4
✓ Branch 0 taken 141060 times.
✓ Branch 1 taken 2140829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 141060 times.
2281889 if(xscale<=0||yscale<=0)
1176 2140829 canscale = false; //default size
1177
1178
4/4
✓ Branch 0 taken 141060 times.
✓ Branch 1 taken 2140829 times.
✓ Branch 2 taken 140626 times.
✓ Branch 3 taken 2000203 times.
2281889 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1179 {
1180 281686 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
1181
1182
1/2
✓ Branch 0 taken 281686 times.
✗ Branch 1 not taken.
281686 if(transparency) //transparency
1183 {
1184 281686 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
1185 281686 }
1186 else //no transparency
1187 {
1188 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
1189 }
1190
1191
2/2
✓ Branch 0 taken 144314 times.
✓ Branch 1 taken 137372 times.
281686 if(rotation != 0)
1192 {
1193 //low negative values indicate no anchor-point rotation
1194
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144314 if(rx>-777||ry>-777)
1195 {
1196 int32_t xy[2];
1197 144314 fixed ra1=itofix(sdci[12]%10000)/10000;
1198 144314 fixed ra2=itofix(sdci[12]/10000);
1199 144314 fixed ra=ra1+ra2;
1200 144314 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1201 144314 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1202 144314 x1=xy[0];
1203 144314 y1=xy[1];
1204 144314 }
1205
1206
2/2
✓ Branch 0 taken 3688 times.
✓ Branch 1 taken 140626 times.
144314 if(canscale) //scale first
1207 {
1208 //damnit all, .. fixme.
1209
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3688 times.
3688 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1210 3688 clear_bitmap(tempbit);
1211
1212 3688 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1213
1214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
3688 if(opacity < 128)
1215 {
1216 clear_bitmap(prim_bmp);
1217 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1218 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1219 }
1220 else
1221 {
1222 3688 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1223 }
1224
1225 3688 destroy_bitmap(tempbit);
1226 3688 }
1227 else //no scale
1228 {
1229
2/2
✓ Branch 0 taken 3586 times.
✓ Branch 1 taken 137040 times.
140626 if(opacity < 128)
1230 {
1231 3586 clear_bitmap(prim_bmp);
1232 3586 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1233 3586 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1234 3586 }
1235 else
1236 {
1237 137040 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1238 }
1239 }
1240 144314 }
1241 else //scale only
1242 {
1243
1/2
✓ Branch 0 taken 137372 times.
✗ Branch 1 not taken.
137372 if(canscale)
1244 {
1245
2/2
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 133028 times.
137372 if(opacity<128)
1246 {
1247 4344 clear_bitmap(prim_bmp);
1248 4344 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1249 4344 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1250 4344 }
1251 else
1252 {
1253 133028 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1254 }
1255 137372 }
1256 else //error -do not scale
1257 {
1258 if(opacity<128)
1259 {
1260 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1261 }
1262 else
1263 {
1264 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1265 }
1266 }
1267 }
1268
1269 281686 script_drawing_commands.ReleaseSubBitmap(pbitty);
1270
1271 281686 }
1272 else // no scale or rotation
1273 {
1274
2/2
✓ Branch 0 taken 1972749 times.
✓ Branch 1 taken 27454 times.
2000203 if(transparency)
1275 {
1276
2/2
✓ Branch 0 taken 224767 times.
✓ Branch 1 taken 1747982 times.
1972749 if(opacity<=127)
1277 224767 TileHelper::OverTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
1278 else
1279 1747982 TileHelper::OverTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
1280 1972749 }
1281 else
1282 {
1283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27454 times.
27454 if(opacity<=127)
1284 TileHelper::PutTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
1285 else
1286 27454 TileHelper::OldPutTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
1287 }
1288 }
1289 2302534 }
1290
1291 void do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1292 {
1293 //sdci[1]=layer
1294 //sdci[2]=x
1295 //sdci[3]=y
1296 //sdci[4]=tile
1297 //sdci[5]=tile width
1298 //sdci[6]=tile height
1299 //sdci[7]=flip
1300
1301 int32_t w = sdci[5]/10000;
1302 int32_t h = sdci[6]/10000;
1303
1304 if(w < 1 || h < 1 || h > 20 || w > 20)
1305 {
1306 return;
1307 }
1308
1309 int32_t flip=(sdci[7]/10000)&3;
1310
1311 int32_t x1=sdci[2]/10000;
1312 int32_t y1=sdci[3]/10000;
1313
1314 TileHelper::OverTileCloaked(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip);
1315 }
1316
1317
1318 2761640 void do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1319 {
1320 //sdci[1]=layer
1321 //sdci[2]=x
1322 //sdci[3]=y
1323 //sdci[4]=combo
1324 //sdci[5]=tile width
1325 //sdci[6]=tile height
1326 //sdci[7]=color (cset)
1327 //sdci[8]=scale x
1328 //sdci[9]=scale y
1329 //sdci[10]=rotation anchor x
1330 //sdci[11]=rotation anchor y
1331 //sdci[12]=rotation angle
1332 //sdci[13]=frame
1333 //sdci[14]=flip
1334 //sdci[15]=transparency
1335 //sdci[16]=opacity
1336
1337 2761640 int32_t w = sdci[5]/10000;
1338 2761640 int32_t h = sdci[6]/10000;
1339
1340
4/8
✓ Branch 0 taken 2761640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2761640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2761640 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2761640 times.
2761640 if(w<1||h<1||h>20||w>20)
1341 {
1342 return;
1343 }
1344 2761640 int32_t cmb = (sdci[4]/10000);
1345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2761640 times.
2761640 if((unsigned)cmb >= MAXCOMBOS)
1346 {
1347 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1348 return;
1349 }
1350
1351 2761640 int32_t xscale=sdci[8]/10000;
1352 2761640 int32_t yscale=sdci[9]/10000;
1353 2761640 int32_t rx = sdci[10]/10000; //these work now
1354 2761640 int32_t ry = sdci[11]/10000; //these work now
1355 2761640 float rotation=sdci[12]/10000;
1356
1357 2761640 bool transparency=sdci[15]!=0;
1358 2761640 int32_t opacity=sdci[16]/10000;
1359 2761640 int32_t color=sdci[7]/10000;
1360 2761640 int32_t x1=sdci[2]/10000;
1361 2761640 int32_t y1=sdci[3]/10000;
1362
1363 2761640 auto& c = GET_DRAWING_COMBO(cmb);
1364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2761640 times.
2761640 if(c.animflags & AF_EDITOR_ONLY) return;
1365 2761640 int32_t tiletodraw = combo_tile(c, x1, y1);
1366 2761640 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
1367 2761640 int32_t skiprows=c.skipanimy;
1368
1369
1370 //don't scale if it's not safe to do so
1371 2761640 bool canscale = true;
1372
1373
3/4
✓ Branch 0 taken 2761567 times.
✓ Branch 1 taken 73 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2761567 times.
2761640 if(xscale==0||yscale==0)
1374 {
1375 73 return;
1376 }
1377
1378
3/4
✓ Branch 0 taken 23422 times.
✓ Branch 1 taken 2738145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23422 times.
2761567 if(xscale<=0||yscale<=0)
1379 2738145 canscale = false; //default size
1380
1381
4/4
✓ Branch 0 taken 23422 times.
✓ Branch 1 taken 2738145 times.
✓ Branch 2 taken 109319 times.
✓ Branch 3 taken 2628826 times.
2761567 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1382 {
1383 132741 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
1384
1385
2/2
✓ Branch 0 taken 131705 times.
✓ Branch 1 taken 1036 times.
132741 if(transparency)
1386 {
1387 131705 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1388 131705 }
1389 else //no transparency
1390 {
1391 1036 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1392 }
1393
1394
2/2
✓ Branch 0 taken 109537 times.
✓ Branch 1 taken 23204 times.
132741 if(rotation != 0) // rotate
1395 {
1396 //fixed point sucks ;0
1397
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 109537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
109537 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
1398 {
1399 int32_t xy[2];
1400 109537 fixed ra1=itofix(sdci[12]%10000)/10000;
1401 109537 fixed ra2=itofix(sdci[12]/10000);
1402 109537 fixed ra=ra1+ra2;
1403 109537 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1404 109537 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1405 109537 x1=xy[0];
1406 109537 y1=xy[1];
1407 109537 }
1408
1409
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109319 times.
109537 if(canscale) //scale first
1410 {
1411
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 218 times.
218 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1412 218 clear_bitmap(tempbit);
1413
1414 218 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1415
1416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if(opacity < 128)
1417 {
1418 clear_bitmap(prim_bmp);
1419 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1420 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1421 }
1422 else
1423 {
1424 218 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1425 }
1426
1427 218 destroy_bitmap(tempbit);
1428 218 }
1429 else //no scale
1430 {
1431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109319 times.
109319 if(opacity < 128)
1432 {
1433 clear_bitmap(prim_bmp);
1434 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1435 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1436 }
1437 else
1438 {
1439 109319 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1440 }
1441 }
1442 109537 }
1443 else //scale only
1444 {
1445
1/2
✓ Branch 0 taken 23204 times.
✗ Branch 1 not taken.
23204 if(canscale)
1446 {
1447
2/2
✓ Branch 0 taken 9395 times.
✓ Branch 1 taken 13809 times.
23204 if(opacity<128)
1448 {
1449 9395 clear_bitmap(prim_bmp);
1450 9395 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1451 9395 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1452 9395 }
1453 else
1454 {
1455 13809 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1456 }
1457 23204 }
1458 else //error -do not scale
1459 {
1460 if(opacity<128)
1461 {
1462 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1463 }
1464 else
1465 {
1466 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1467 }
1468 }
1469 }
1470
1471 132741 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
1472 132741 }
1473 else // no scale or rotation
1474 {
1475
1/2
✓ Branch 0 taken 2628826 times.
✗ Branch 1 not taken.
2628826 if(transparency)
1476 {
1477
2/2
✓ Branch 0 taken 64341 times.
✓ Branch 1 taken 2564485 times.
2628826 if(opacity<=127)
1478 64341 TileHelper::OverTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1479 else
1480 2564485 TileHelper::OverTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1481 2628826 }
1482 else
1483 {
1484 if(opacity<=127)
1485 TileHelper::PutTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1486 else
1487 TileHelper::OldPutTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1488 }
1489 }
1490 2761640 }
1491
1492 void do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1493 {
1494 //sdci[1]=layer
1495 //sdci[2]=x
1496 //sdci[3]=y
1497 //sdci[4]=combo
1498 //sdci[5]=tile width
1499 //sdci[6]=tile height
1500 //sdci[7]=flip
1501
1502 int32_t w = sdci[5]/10000;
1503 int32_t h = sdci[6]/10000;
1504
1505 if(w<1||h<1||h>20||w>20)
1506 {
1507 return;
1508 }
1509 int32_t cmb = (sdci[4]/10000);
1510 if((unsigned)cmb >= MAXCOMBOS)
1511 {
1512 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1513 return;
1514 }
1515
1516 int32_t x1=sdci[2]/10000;
1517 int32_t y1=sdci[3]/10000;
1518
1519 auto& c = GET_DRAWING_COMBO(cmb);
1520 int32_t tiletodraw = combo_tile(c, x1, y1);
1521 if(c.animflags & AF_EDITOR_ONLY) return;
1522 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
1523 int32_t skiprows=c.skipanimy;
1524
1525 TileHelper::OverTileCloaked(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
1526 }
1527
1528
1529 5327982 void do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1530 {
1531 /* layer, x, y, tile, color opacity */
1532
1533 5327982 int32_t opacity = sdci[6]/10000;
1534 5327982 int x = xoffset+(sdci[2]/10000);
1535 5327982 int y = yoffset+(sdci[3]/10000);
1536
1537
2/2
✓ Branch 0 taken 154230 times.
✓ Branch 1 taken 5173752 times.
5327982 if(opacity < 128)
1538 154230 overtiletranslucent16(bmp, sdci[4]/10000, x, y, sdci[5]/10000, 0, opacity);
1539 else
1540 5173752 overtile16(bmp, sdci[4]/10000, x, y, sdci[5]/10000, 0);
1541 5327982 }
1542
1543 void do_fasttilesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1544 {
1545 /* layer, x, y, tile, color opacity */
1546
1547 //sdci[1]=layer
1548 //sdci[2]=array {x,y,tile,colour,opacity}
1549
1550 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1551
1552 if(!v_ptr)
1553 {
1554 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1555 return;
1556 }
1557
1558 std::vector<int32_t> &v = *v_ptr;
1559
1560 if(v.empty())
1561 return;
1562
1563 int32_t* pos = &v[0];
1564 int32_t sz = v.size();
1565
1566 for ( int32_t q = 0; q < sz; q+=5 )
1567 {
1568
1569 if(v.at(q+4) < 128)
1570 overtiletranslucent16(bmp, v.at(q+2), xoffset+(v.at(q)), yoffset+(v.at(q+1)), v.at(q+3), 0, v.at(q+4));
1571 else
1572 overtile16(bmp, v.at(q+2), xoffset+(v.at(q)), yoffset+(v.at(q+1)), v.at(q+3), 0);
1573 }
1574 }
1575
1576
1577
1578 30255774 void do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1579 {
1580 /* layer, x, y, tile, color opacity */
1581
1582 30255774 int32_t opacity = sdci[6] / 10000;
1583 30255774 int32_t x1 = sdci[2] / 10000;
1584 30255774 int32_t y1 = sdci[3] / 10000;
1585
1586 30255774 int32_t cmb = (sdci[4]/10000);
1587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30255774 times.
30255774 if((unsigned)cmb >= MAXCOMBOS)
1588 {
1589 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1590 return;
1591 }
1592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30255774 times.
30255774 if(combobuf[cmb].animflags & AF_EDITOR_ONLY) return;
1593
1594 30255774 int x = xoffset+x1;
1595 30255774 int y = yoffset+y1;
1596
1597
2/2
✓ Branch 0 taken 7829244 times.
✓ Branch 1 taken 22426530 times.
30255774 if(opacity < 128)
1598 {
1599 7829244 overcomboblocktranslucent(bmp, x, y, cmb, sdci[5]/10000, 1, 1, 128);
1600 7829244 }
1601 else
1602 {
1603 22426530 overcomboblock(bmp, x, y, cmb, sdci[5]/10000, 1, 1);
1604 }
1605 30255774 }
1606
1607 void do_fastcombosr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1608 {
1609 /* layer, x, y, combo, cset, opacity */
1610 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1611
1612 if(!v_ptr)
1613 {
1614 al_trace("Screen->FastCombos: Vector pointer is null! Internal error. \n");
1615 return;
1616 }
1617
1618 std::vector<int32_t> &v = *v_ptr;
1619
1620 if(v.empty())
1621 return;
1622
1623 int32_t* pos = &v[0];
1624 int32_t sz = v.size();
1625
1626 for ( int32_t q = 0; q < sz; q+=5 )
1627 {
1628 auto cid = v.at(q+2);
1629 if((unsigned)(cid) >= MAXCOMBOS)
1630 {
1631 Z_scripterrlog("FastCombos() cannot draw combo '%d', as it is out of bounds.\n", v.at(q+2));
1632 continue;
1633 }
1634 if(combobuf[cid].animflags & AF_EDITOR_ONLY) continue;
1635 if(v.at(q+4) < 128)
1636 {
1637 overcomboblocktranslucent(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1, 128);
1638
1639 }
1640 else
1641 {
1642 overcomboblock(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1);
1643 }
1644 }
1645 }
1646
1647
1648
1649
1650 964027 void do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1651 {
1652 //broken 2.50.2 and earlier drawcharacter()
1653
2/2
✓ Branch 0 taken 18543 times.
✓ Branch 1 taken 945484 times.
964027 if ( get_qr(qr_BROKENCHARINTDRAWING) )
1654 {
1655 //sdci[1]=layer
1656 //sdci[2]=x
1657 //sdci[3]=y
1658 //sdci[4]=font
1659 //sdci[5]=color
1660 //sdci[6]=bg color
1661 //sdci[7]=strech x (width)
1662 //sdci[8]=stretch y (height)
1663 //sdci[9]=char
1664 //sdci[10]=opacity
1665
1666 18543 int32_t x=sdci[2]/10000;
1667 18543 int32_t y=sdci[3]/10000;
1668 18543 int32_t font_index=sdci[4]/10000;
1669 18543 int32_t color=sdci[5]/10000;
1670 18543 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1671 18543 int32_t w=sdci[7]/10000;
1672 18543 int32_t h=sdci[8]/10000;
1673 18543 char glyph=char(sdci[9]/10000);
1674 18543 int32_t opacity=sdci[10]/10000;
1675
1676 //safe check
1677
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(bg_color < -1) bg_color = -1;
1678
1679
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(w>512) w=512; //w=vbound(w,0,512);
1680
1681
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(h>512) h=512; //h=vbound(h,0,512);
1682
1683 //undone
1684
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18543 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18543 if(w>0&&h>0)//stretch the character
1685 {
1686 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1687
1688 if(opacity < 128)
1689 {
1690 if(w>128||h>128)
1691 {
1692 clear_bitmap(prim_bmp);
1693
1694 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1695 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1696 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1697 }
1698 else //this is faster
1699 {
1700 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1701
1702 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1703 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1704 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1705
1706 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1707 }
1708 }
1709 else // no opacity
1710 {
1711 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1712 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1713 }
1714
1715 }
1716 else //no stretch
1717 {
1718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18543 times.
18543 if(opacity < 128)
1719 {
1720 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1721 clear_bitmap(pbmp);
1722
1723 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1724 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1725
1726 destroy_bitmap(pbmp);
1727 }
1728 else // no opacity
1729 {
1730 18543 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1731 }
1732 }
1733 18543 }
1734
1735 else //2.53.0 fixed version and later.
1736 {
1737
1738 //sdci[1]=layer
1739 //sdci[2]=x
1740 //sdci[3]=y
1741 //sdci[4]=font
1742 //sdci[5]=color
1743 //sdci[6]=bg color
1744 //sdci[7]=strech x (width)
1745 //sdci[8]=stretch y (height)
1746 //sdci[9]=char
1747 //sdci[10]=opacity
1748
1749 945484 int32_t x=sdci[2]/10000;
1750 945484 int32_t y=sdci[3]/10000;
1751 945484 int32_t font_index=sdci[4]/10000;
1752 945484 int32_t color=sdci[5]/10000;
1753 945484 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1754 945484 int32_t w=sdci[7]/10000;
1755 945484 int32_t h=sdci[8]/10000;
1756 945484 char glyph=char(sdci[9]/10000);
1757 945484 int32_t opacity=sdci[10]/10000;
1758
1759 //safe check
1760
1/2
✓ Branch 0 taken 945484 times.
✗ Branch 1 not taken.
945484 if(bg_color < -1) bg_color = -1;
1761
1762
1/2
✓ Branch 0 taken 945484 times.
✗ Branch 1 not taken.
945484 if(w>512) w=512; //w=vbound(w,0,512);
1763
1764
1/2
✓ Branch 0 taken 945484 times.
✗ Branch 1 not taken.
945484 if(h>512) h=512; //h=vbound(h,0,512);
1765
1766 //undone
1767
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 945484 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
945484 if(w>0&&h>0)//stretch the character
1768 {
1769 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1770
1771 if(opacity < 128)
1772 {
1773 if(w>128||h>128)
1774 {
1775 clear_bitmap(prim_bmp);
1776
1777 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1778 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1779 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1780 }
1781 else //this is faster
1782 {
1783 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1784
1785 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1786 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1787 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1788
1789 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1790 }
1791 }
1792 else // no opacity
1793 {
1794 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1795 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1796 }
1797
1798 }
1799 else //no stretch
1800 {
1801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945484 times.
945484 if(opacity < 128)
1802 {
1803 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1804 clear_bitmap(pbmp);
1805
1806 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1807 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1808
1809 destroy_bitmap(pbmp);
1810 }
1811 else // no opacity
1812 {
1813 945484 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1814 }
1815 }
1816
1817 }
1818
1819 964027 }
1820
1821
1822 176452 void do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1823 {
1824 //broken 2.50.2 and earlier drawinteger()
1825
2/2
✓ Branch 0 taken 72655 times.
✓ Branch 1 taken 103797 times.
176452 if ( get_qr(qr_BROKENCHARINTDRAWING) )
1826 {
1827 //sdci[1]=layer
1828 //sdci[2]=x
1829 //sdci[3]=y
1830 //sdci[4]=font
1831 //sdci[5]=color
1832 //sdci[6]=bg color
1833 //sdci[7]=strech x (width)
1834 //sdci[8]=stretch y (height)
1835 //sdci[9]=integer
1836 //sdci[10]=num decimal places
1837 //sdci[11]=opacity
1838
1839 72655 int32_t x=sdci[2]/10000;
1840 72655 int32_t y=sdci[3]/10000;
1841 72655 int32_t font_index=sdci[4]/10000;
1842 72655 int32_t color=sdci[5]/10000;
1843 72655 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1844 72655 int32_t w=sdci[7]/10000;
1845 72655 int32_t h=sdci[8]/10000;
1846 72655 int32_t decplace=sdci[10]/10000;
1847 72655 int32_t opacity=sdci[11]/10000;
1848
1849 //safe check
1850
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(bg_color < -1) bg_color = -1;
1851
1852
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(w>512) w=512; //w=vbound(w,0,512);
1853
1854
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(h>512) h=512; //h=vbound(h,0,512);
1855
1856 char numbuf[15];
1857
1858
1/6
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
72655 switch(decplace)
1859 {
1860 default:
1861 case 0:
1862 72655 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1863 72655 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1864
1865 case 1:
1866 //sprintf(numbuf,"%.01f",number);
1867 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1868 break;
1869
1870 case 2:
1871 //sprintf(numbuf,"%.02f",number);
1872 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1873 break;
1874
1875 case 3:
1876 //sprintf(numbuf,"%.03f",number);
1877 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1878 break;
1879
1880 case 4:
1881 //sprintf(numbuf,"%.04f",number);
1882 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1883 break;
1884 }
1885
1886
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72655 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72655 if(w>0&&h>0)//stretch
1887 {
1888 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1889
1890 if(opacity < 128)
1891 {
1892 if(w>128||h>128)
1893 {
1894 clear_bitmap(prim_bmp);
1895
1896 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1897 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1898 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1899 }
1900 else
1901 {
1902 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
1903 clear_bitmap(pbmp2);
1904
1905 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1906 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1907 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1908
1909 destroy_bitmap(pbmp2);
1910 }
1911 }
1912 else // no opacity
1913 {
1914 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1915 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1916 }
1917
1918 }
1919 else //no stretch
1920 {
1921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72655 times.
72655 if(opacity < 128)
1922 {
1923 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1924 clear_bitmap(pbmp);
1925
1926 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1927 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1928
1929 destroy_bitmap(pbmp);
1930 }
1931 else // no opacity
1932 {
1933 72655 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
1934 }
1935 }
1936
1937 72655 }
1938
1939 else //2.53.0 fixed version and later.
1940 {
1941 //sdci[1]=layer
1942 //sdci[2]=x
1943 //sdci[3]=y
1944 //sdci[4]=font
1945 //sdci[5]=color
1946 //sdci[6]=bg color
1947 //sdci[7]=strech x (width)
1948 //sdci[8]=stretch y (height)
1949 //sdci[9]=integer
1950 //sdci[10]=num decimal places
1951 //sdci[11]=opacity
1952
1953 103797 int32_t x=sdci[2]/10000;
1954 103797 int32_t y=sdci[3]/10000;
1955 103797 int32_t font_index=sdci[4]/10000;
1956 103797 int32_t color=sdci[5]/10000;
1957 103797 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1958 103797 int32_t w=sdci[7]/10000;
1959 103797 int32_t h=sdci[8]/10000;
1960 103797 int32_t decplace=sdci[10]/10000;
1961 103797 int32_t opacity=sdci[11]/10000;
1962
1963 //safe check
1964
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(bg_color < -1) bg_color = -1;
1965
1966
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(w>512) w=512; //w=vbound(w,0,512);
1967
1968
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(h>512) h=512; //h=vbound(h,0,512);
1969
1970 char numbuf[15];
1971
1972
1/6
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
103797 switch(decplace)
1973 {
1974 default:
1975 case 0:
1976 103797 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1977 103797 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1978
1979 case 1:
1980 //sprintf(numbuf,"%.01f",number);
1981 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1982 break;
1983
1984 case 2:
1985 //sprintf(numbuf,"%.02f",number);
1986 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1987 break;
1988
1989 case 3:
1990 //sprintf(numbuf,"%.03f",number);
1991 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1992 break;
1993
1994 case 4:
1995 //sprintf(numbuf,"%.04f",number);
1996 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1997 break;
1998 }
1999
2000 //FONT* font=get_zc_font(sdci[4]/10000);
2001
2002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 103797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
103797 if(w>0&&h>0)//stretch
2003 {
2004 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
2005 clear_bitmap(pbmp);
2006 //script_drawing_commands.GetSmallTextureBitmap(1,1);
2007
2008 if(opacity < 128)
2009 {
2010 if(w>128||h>128)
2011 {
2012 clear_bitmap(prim_bmp);
2013
2014 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
2015 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
2016 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
2017 }
2018 else
2019 {
2020 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
2021 clear_bitmap(pbmp2);
2022
2023 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
2024 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
2025 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
2026
2027 destroy_bitmap(pbmp2);
2028 }
2029 }
2030 else // no opacity
2031 {
2032 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
2033 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
2034 }
2035
2036 }
2037 else //no stretch
2038 {
2039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103797 times.
103797 if(opacity < 128)
2040 {
2041 FONT* font = get_zc_font(font_index);
2042 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
2043 clear_bitmap(pbmp);
2044
2045 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
2046 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2047
2048 destroy_bitmap(pbmp);
2049 }
2050 else // no opacity
2051 {
2052 103797 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
2053 }
2054 }
2055 }
2056 176452 }
2057
2058
2059 1607511 void do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2060 {
2061 //sdci[1]=layer
2062 //sdci[2]=x
2063 //sdci[3]=y
2064 //sdci[4]=font
2065 //sdci[5]=color
2066 //sdci[6]=bg color
2067 //sdci[7]=format_option
2068 //sdci[8]=string
2069 //sdci[9]=opacity
2070
2071 1607511 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2072
2073
1/2
✓ Branch 0 taken 1607511 times.
✗ Branch 1 not taken.
1607511 if(!str)
2074 {
2075 al_trace("String pointer is null! Internal error. \n");
2076 return;
2077 }
2078
2079 1607511 int32_t x=sdci[2]/10000;
2080 1607511 int32_t y=sdci[3]/10000;
2081 1607511 FONT* font=get_zc_font(sdci[4]/10000);
2082 1607511 int32_t color=sdci[5]/10000;
2083 1607511 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2084 1607511 int32_t format_type=sdci[7]/10000;
2085 1607511 int32_t opacity=sdci[9]/10000;
2086 //sdci[8] not needed :)
2087
2088 //safe check
2089
1/2
✓ Branch 0 taken 1607511 times.
✗ Branch 1 not taken.
1607511 if(bg_color < -1) bg_color = -1;
2090
2091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1607511 times.
1607511 if(opacity < 128)
2092 {
2093 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2094 if (width < 1) return; //SANITY -Em
2095 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2096 clear_bitmap(pbmp);
2097 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2098 if(format_type == 2) // right-sided text
2099 x-=width;
2100 else if(format_type == 1) // centered text
2101 x-=width/2;
2102 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2103 destroy_bitmap(pbmp);
2104 }
2105 else // no opacity
2106 {
2107
2/2
✓ Branch 0 taken 14345 times.
✓ Branch 1 taken 1593166 times.
1607511 if(format_type == 2) // right-sided text
2108 {
2109 14345 textout_right_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2110 14345 }
2111
2/2
✓ Branch 0 taken 725712 times.
✓ Branch 1 taken 867454 times.
1593166 else if(format_type == 1) // centered text
2112 {
2113 725712 textout_centre_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2114 725712 }
2115 else // standard left-sided text
2116 {
2117 867454 textout_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2118 }
2119 }
2120 1607511 }
2121
2122 201739 void do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2123 {
2124 //sdci[1]=layer
2125 //sdci[2]=x
2126 //sdci[3]=y
2127 //sdci[4]=font
2128 //sdci[5]=color
2129 //sdci[6]=bg color
2130 //sdci[7]=format_option
2131 //sdci[8]=string
2132 //sdci[9]=opacity
2133 //sdci[10]=shadowtype
2134 //sdci[11]=shadow_color
2135
2136 201739 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2137
2138
1/2
✓ Branch 0 taken 201739 times.
✗ Branch 1 not taken.
201739 if(!str)
2139 {
2140 al_trace("String pointer is null! Internal error. \n");
2141 return;
2142 }
2143
2144 201739 int32_t x=sdci[2]/10000;
2145 201739 int32_t y=sdci[3]/10000;
2146 201739 FONT* font=get_zc_font(sdci[4]/10000);
2147 201739 int32_t color=sdci[5]/10000;
2148 201739 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2149 201739 int32_t format_type=sdci[7]/10000;
2150 201739 int32_t opacity=sdci[9]/10000;
2151 201739 int32_t textstyle = sdci[10]/10000;
2152 201739 int32_t shadow_color = sdci[11]/10000;
2153 //sdci[8] not needed :)
2154
2155 //safe check
2156
1/2
✓ Branch 0 taken 201739 times.
✗ Branch 1 not taken.
201739 if(bg_color < -1) bg_color = -1;
2157
2158
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 200999 times.
201739 if(opacity < 128)
2159 {
2160
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2161
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if (width < 1) return; //SANITY -Em
2162 740 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2163 740 clear_bitmap(pbmp);
2164 740 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, sstaLEFT, color, shadow_color, bg_color);
2165 740 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
740 if(format_type == 2) // right-sided text
2167 x-=width;
2168
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 else if(format_type == 1) // centered text
2169 740 x-=width/2;
2170 740 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2171 740 destroy_bitmap(pbmp);
2172 740 }
2173 else // no opacity
2174 {
2175 200999 textout_styled_aligned_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
2176 }
2177 201739 }
2178
2179
2180 9266 void do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2181 {
2182 //sdci[1]=layer
2183 //sdci[2]=x1
2184 //sdci[3]=y1
2185 //sdci[4]=x2
2186 //sdci[5]=y2
2187 //sdci[6]=x3
2188 //sdci[7]=y3
2189 //sdci[8]=x4
2190 //sdci[9]=y4
2191 //sdci[10]=width
2192 //sdci[11]=height
2193 //sdci[12]=cset
2194 //sdci[13]=flip
2195 //sdci[14]=tile/combo
2196 //sdci[15]=polytype
2197
2198 9266 int32_t x1 = sdci[2]/10000;
2199 9266 int32_t y1 = sdci[3]/10000;
2200 9266 int32_t x2 = sdci[4]/10000;
2201 9266 int32_t y2 = sdci[5]/10000;
2202 9266 int32_t x3 = sdci[6]/10000;
2203 9266 int32_t y3 = sdci[7]/10000;
2204 9266 int32_t x4 = sdci[8]/10000;
2205 9266 int32_t y4 = sdci[9]/10000;
2206 9266 int32_t w = sdci[10]/10000;
2207 9266 int32_t h = sdci[11]/10000;
2208 9266 int32_t color = sdci[12]/10000;
2209 9266 int32_t flip=(sdci[13]/10000)&3;
2210 9266 int32_t tile = sdci[14]/10000;
2211 9266 int32_t polytype = sdci[15]/10000;
2212
2213 //todo: finish palette shading
2214 /*
2215 POLYTYPE_FLAT
2216 POLYTYPE_GCOL
2217 POLYTYPE_GRGB
2218 POLYTYPE_ATEX
2219 POLYTYPE_PTEX
2220 POLYTYPE_ATEX_MASK
2221 POLYTYPE_PTEX_MASK
2222 POLYTYPE_ATEX_LIT
2223 POLYTYPE_PTEX_LIT
2224 POLYTYPE_ATEX_MASK_LIT
2225 POLYTYPE_PTEX_MASK_LIT
2226 POLYTYPE_ATEX_TRANS
2227 POLYTYPE_PTEX_TRANS
2228 POLYTYPE_ATEX_MASK_TRANS
2229 POLYTYPE_PTEX_MASK_TRANS
2230 */
2231 9266 polytype = vbound(polytype, 0, 14);
2232
2233
2/4
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9266 times.
9266 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2234 {
2235 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2236 return; //non power of two error
2237 }
2238
2239 9266 int32_t tex_width = w*16;
2240 9266 int32_t tex_height = h*16;
2241
2242 BITMAP *tex;
2243
2244 9266 bool mustDestroyBmp = false;
2245
2246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if ( tile > 65519 ) tex = zscriptDrawingRenderTarget->GetBitmapPtr(tile - 65519);
2247 9266 else tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2248
2249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if(!tex)
2250 {
2251 mustDestroyBmp = true;
2252 tex = create_bitmap_ex(8, tex_width, tex_height);
2253 clear_bitmap(tex);
2254 }
2255
2256 int32_t col[4];
2257 /*
2258 if( color < 0 )
2259 {
2260 col[0]=draw_container.color_buffer[0];
2261 col[1]=draw_container.color_buffer[1];
2262 col[2]=draw_container.color_buffer[2];
2263 col[3]=draw_container.color_buffer[3];
2264 }
2265 else */
2266 {
2267 9266 col[0]=col[1]=col[2]=col[3]=color;
2268 }
2269
2270
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9266 if(tile > 0 && tile <= 65519) // TILE
2271 {
2272 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2273 }
2274
2275
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if ( tile < 0 ) // COMBO
2276 {
2277 9266 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
2278 9266 const int32_t tiletodraw = combo_tile(c, x1, y1);
2279 9266 flip = flip ^ c.flip;
2280
2281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if(!(c.animflags & AF_EDITOR_ONLY))
2282 9266 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2283 9266 }
2284
2285 9266 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2286 9266 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2287 9266 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2288 9266 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(tex_width), 0, col[3] };
2289
2290 9266 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
2291
2292
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if(mustDestroyBmp)
2293 destroy_bitmap(tex);
2294
2295 9266 }
2296
2297
2298 void do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2299 {
2300 //sdci[1]=layer
2301 //sdci[2]=x1
2302 //sdci[3]=y1
2303 //sdci[4]=x2
2304 //sdci[5]=y2
2305 //sdci[6]=x3
2306 //sdci[7]=y3
2307 //sdci[8]=width
2308 //sdci[9]=height
2309 //sdci[10]=cset
2310 //sdci[11]=flip
2311 //sdci[12]=tile/combo
2312 //sdci[13]=polytype
2313
2314 int32_t x1 = sdci[2]/10000;
2315 int32_t y1 = sdci[3]/10000;
2316 int32_t x2 = sdci[4]/10000;
2317 int32_t y2 = sdci[5]/10000;
2318 int32_t x3 = sdci[6]/10000;
2319 int32_t y3 = sdci[7]/10000;
2320 int32_t w = sdci[8]/10000;
2321 int32_t h = sdci[9]/10000;
2322 int32_t color = sdci[10]/10000;
2323 int32_t flip=(sdci[11]/10000)&3;
2324 int32_t tile = sdci[12]/10000;
2325 int32_t polytype = sdci[13]/10000;
2326
2327 polytype = vbound(polytype, 0, 14);
2328
2329 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2330 {
2331 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2332 return; //non power of two error
2333 }
2334
2335 int32_t tex_width = w*16;
2336 int32_t tex_height = h*16;
2337
2338 bool mustDestroyBmp = false;
2339 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2340
2341 if(!tex)
2342 {
2343 mustDestroyBmp = true;
2344 tex = create_bitmap_ex(8, tex_width, tex_height);
2345 clear_bitmap(tex);
2346 }
2347
2348 int32_t col[3];
2349 /*
2350 if( color < 0 )
2351 {
2352 col[0]=draw_container.color_buffer[0];
2353 col[1]=draw_container.color_buffer[1];
2354 col[2]=draw_container.color_buffer[2];
2355 }
2356 else */
2357 {
2358 col[0]=col[1]=col[2]=color;
2359 }
2360
2361 if(tile > 0) // TILE
2362 {
2363 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2364 }
2365 else // COMBO
2366 {
2367 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
2368 const int32_t tiletodraw = combo_tile(c, x1, y1);
2369 flip = flip ^ c.flip;
2370
2371 if(!(c.animflags & AF_EDITOR_ONLY))
2372 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2373 }
2374
2375 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2376 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2377 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2378
2379
2380 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
2381
2382 if(mustDestroyBmp)
2383 destroy_bitmap(tex);
2384 }
2385
2386
2387 936403 void do_drawbitmapr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2388 {
2389 //sdci[1]=layer
2390 //sdci[2]=bitmap
2391 //sdci[3]=sourcex
2392 //sdci[4]=sourcey
2393 //sdci[5]=sourcew
2394 //sdci[6]=sourceh
2395 //sdci[7]=destx
2396 //sdci[8]=desty
2397 //sdci[9]=destw
2398 //sdci[10]=desth
2399 //sdci[11]=rotation
2400 //sdci[12]=mask
2401
2402 936403 int32_t bitmapIndex = sdci[2]/10000;
2403 936403 int32_t sx = sdci[3]/10000;
2404 936403 int32_t sy = sdci[4]/10000;
2405 936403 int32_t sw = sdci[5]/10000;
2406 936403 int32_t sh = sdci[6]/10000;
2407 936403 int32_t dx = sdci[7]/10000;
2408 936403 int32_t dy = sdci[8]/10000;
2409 936403 int32_t dw = sdci[9]/10000;
2410 936403 int32_t dh = sdci[10]/10000;
2411 936403 float rot = sdci[11]/10000;
2412 936403 bool masked = (sdci[12] != 0);
2413
2414 //bugfix
2415 936403 sx = vbound(sx, 0, 512);
2416 936403 sy = vbound(sy, 0, 512);
2417 936403 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2418 936403 sh = vbound(sh, 0, 512 - sy);
2419
2420
2421
2/4
✓ Branch 0 taken 936403 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 936403 times.
936403 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2422 return;
2423
2424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 936403 times.
936403 bool stretched = (sw != dw || sh != dh);
2425
2426 936403 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2427
2428
1/2
✓ Branch 0 taken 936403 times.
✗ Branch 1 not taken.
936403 if(!sourceBitmap)
2429 {
2430 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2431 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2432 return;
2433 }
2434
2435 936403 BITMAP* subBmp = 0;
2436
2437
1/2
✓ Branch 0 taken 936403 times.
✗ Branch 1 not taken.
936403 if(rot != 0)
2438 {
2439 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2440
2441 if(!subBmp)
2442 {
2443 Z_scripterrlog("DrawBitmap() failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2444 return;
2445 }
2446 }
2447
2448
2449 936403 dx = dx + xoffset;
2450 936403 dy = dy + yoffset;
2451
2452
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 936163 times.
936403 if(stretched)
2453 {
2454
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(masked)
2455 {
2456
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(rot != 0)
2457 {
2458 //if ( rot == 4096 ) { //translucent
2459 // masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2460 // //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2461 // draw_trans_sprite(bmp, subBmp, dx, dy);
2462 // //draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, 0);
2463
2464
2465 // }
2466 //else {
2467 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2468 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2469 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2470 //
2471
2472 // }
2473 }
2474 else
2475 240 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2476 240 }
2477 else
2478 {
2479 if(rot != 0)
2480 {
2481 //if ( rot == 4096 ) { //translucent
2482 // stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2483 // draw_trans_sprite(bmp, subBmp, dx, dy);
2484 // }
2485 //else {
2486 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2487 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2488 // }
2489 }
2490 else
2491 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2492 }
2493 240 }
2494 else
2495 {
2496
2/2
✓ Branch 0 taken 928675 times.
✓ Branch 1 taken 7488 times.
936163 if(masked)
2497 {
2498
1/2
✓ Branch 0 taken 928675 times.
✗ Branch 1 not taken.
928675 if(rot != 0)
2499 {
2500 //if ( rot == 4096 ) {//translucent
2501 // masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2502 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2503
2504 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2505 //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2506 // draw_trans_sprite(bmp, subBmp, dx, dy);
2507 // }
2508 //else {
2509 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2510 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2511 // }
2512 }
2513 else
2514 928675 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2515 928675 }
2516 else
2517 {
2518
1/2
✓ Branch 0 taken 7488 times.
✗ Branch 1 not taken.
7488 if(rot != 0)
2519 {
2520 //if ( rot == 4096 ) { //translucent
2521 // blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2522 // draw_trans_sprite(bmp, subBmp, dx, dy);
2523 // }
2524 //else {
2525 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2526 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2527 // }
2528 }
2529 else
2530 7488 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2531 }
2532 }
2533
2534 //cleanup
2535
1/2
✓ Branch 0 taken 936403 times.
✗ Branch 1 not taken.
936403 if(subBmp)
2536 {
2537 script_drawing_commands.ReleaseSubBitmap(subBmp);
2538 }
2539 936403 }
2540
2541
2542 //Draw]()
2543 void do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2544 {
2545 /*
2546 //sdci[1]=layer
2547 //sdci[2]=bitmap
2548 //sdci[3]=sourcex
2549 //sdci[4]=sourcey
2550 //sdci[5]=sourcew
2551 //sdci[6]=sourceh
2552 //sdci[7]=destx
2553 //sdci[8]=desty
2554 //sdci[9]=destw
2555 //sdci[10]=desth
2556 //sdci[11]=rotation/angle
2557 //scdi[12] = pivot cx
2558 //sdci[13] = pivot cy
2559 //scdi[14] = effect flags
2560
2561
2562 const int32_t BITDX_NORMAL = 0;
2563 const int32_t BITDX_TRANS = 1; //Translucent
2564 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
2565 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
2566 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
2567 //Note: Some modes cannot be combined. if a combination is not supported, an error
2568 // detailing this will be shown in allegro.log.
2569
2570 //scdi[15] = litcolour
2571 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2572 /not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2573
2574 //sdci[16]=mask
2575
2576 */
2577
2578 int32_t bitmapIndex = sdci[2]/10000;
2579 int32_t sx = sdci[3]/10000;
2580 int32_t sy = sdci[4]/10000;
2581 int32_t sw = sdci[5]/10000;
2582 int32_t sh = sdci[6]/10000;
2583 int32_t dx = sdci[7]/10000;
2584 int32_t dy = sdci[8]/10000;
2585 int32_t dw = sdci[9]/10000;
2586 int32_t dh = sdci[10]/10000;
2587 float rot = sdci[11]/10000;
2588 int32_t cx = sdci[12]/10000;
2589 int32_t cy = sdci[13]/10000;
2590 int32_t mode = sdci[14]/10000;
2591 int32_t litcolour = sdci[15]/10000;
2592 bool masked = (sdci[16] != 0);
2593
2594
2595
2596 //bugfix
2597 sx = vbound(sx, 0, 512);
2598 sy = vbound(sy, 0, 512);
2599 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2600 sh = vbound(sh, 0, 512 - sy);
2601
2602
2603 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2604 return;
2605
2606 bool stretched = (sw != dw || sh != dh);
2607
2608 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2609
2610 if(!sourceBitmap)
2611 {
2612 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2613 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2614 return;
2615 }
2616
2617 BITMAP* subBmp = 0;
2618
2619 /*
2620 if ( bitmapIndex == -1 ) {
2621 blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh);
2622 }
2623 */
2624
2625 if(rot != 0 || mode != 0)
2626 {
2627 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2628
2629 if(!subBmp)
2630 {
2631 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2632 return;
2633 }
2634 }
2635
2636
2637 dx = dx + xoffset;
2638 dy = dy + yoffset;
2639
2640 if(stretched)
2641 {
2642 if(masked) //stretched and masked
2643 {
2644 if ( rot == 0 ) //if not rotated
2645 {
2646 switch(mode)
2647 {
2648 case 1:
2649 //transparent
2650 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2651 draw_trans_sprite(bmp, subBmp, dx, dy);
2652 break;
2653
2654
2655 case 2:
2656 //pivot?
2657 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2658 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2659 //Pivoting requires two more args
2660 break;
2661
2662 case 3:
2663 //pivot + trans
2664 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2665 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2666 break;
2667
2668 case 4:
2669 //flip v
2670 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2671 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2672 break;
2673
2674 case 5:
2675 //trans + v flip
2676 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2677 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2678 break;
2679
2680 case 6:
2681 //pivot + v flip
2682 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2683 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2684 break;
2685
2686 case 8:
2687 //vlip h
2688 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2689 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2690 break;
2691
2692 case 9:
2693 //trans + h flip
2694 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2695 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2696 break;
2697
2698 case 10:
2699 //flip H and pivot
2700 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2701 //return error cannot pivot and h flip
2702 break;
2703
2704 case 12:
2705 //vh flip
2706 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2707 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2708 break;
2709
2710 case 13:
2711 //trans + vh flip
2712 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2713 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2714 break;
2715
2716 case 14:
2717 //pivot and vh flip
2718 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2719 //return error cannot both pivot and vh flip
2720 break;
2721
2722 case 16:
2723 //lit
2724 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2725 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
2726 break;
2727
2728 case 18:
2729 //pivot, lit
2730 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2731 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2732 break;
2733
2734 case 20:
2735 //lit + v flip
2736 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2737 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
2738 break;
2739
2740 case 22:
2741 //Pivot, vflip, lit
2742 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2743 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2744 break;
2745
2746 case 24:
2747 //lit + h flip
2748 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2749 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
2750 break;
2751
2752 case 26:
2753 //pivot + lit + hflip
2754 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
2755 //return error cannot pivot, lit, and flip
2756 break;
2757
2758 case 28:
2759 //lit + vh flip
2760 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2761 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
2762 break;
2763
2764 case 32: //gouraud
2765 //Probably not wort supporting.
2766 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2767 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2768 break;
2769
2770 case 0:
2771 //no effect
2772 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2773 break;
2774
2775
2776 default:
2777 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2778
2779
2780 }
2781 } //end if not rotated
2782
2783 if ( rot != 0 ) //if rotated
2784 {
2785 switch(mode)
2786 {
2787 case 1:
2788 //transparent
2789 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2790 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2791
2792 break;
2793
2794 case 2:
2795 //pivot?
2796 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2797 //return an error, cannot both rotate and pivot
2798 break;
2799
2800 case 3:
2801 //pivot + trans
2802 //return an error, cannot both rotate and pivot
2803 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2804 break;
2805
2806 case 4:
2807 //flip v
2808 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2809 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2810 break;
2811
2812 case 5:
2813 //trans + v flip
2814 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2815 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2816 break;
2817
2818 case 6:
2819 //pivot + v flip
2820 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2821 //return an error, cannot both rotate and pivot
2822 break;
2823
2824 case 8:
2825 //flip h
2826 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
2827 //return an error, cannot both rotate and flip H
2828 break;
2829
2830 case 9:
2831 //trans + h flip
2832 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
2833 //return an error, cannot rotate and flip a trans sprite
2834 break;
2835
2836 case 10:
2837 //flip H and pivot
2838 //return error cannot pivot and h flip
2839 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2840 break;
2841
2842 case 12:
2843 //vh flip
2844 //return an error, cannot rotate and VH flip a trans sprite
2845 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2846 break;
2847
2848 case 13:
2849 //trans + vh flip
2850 //return an error, cannot rotate and VH flip a trans sprite
2851 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2852 break;
2853
2854 case 14:
2855 //pivot and vh flip
2856 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2857 //return error cannot both pivot and vh flip
2858 break;
2859
2860 case 16:
2861 //lit
2862 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2863 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2864 break;
2865
2866 case 18:
2867 //pivot, lit
2868 //return an error, cannot both rotate and pivot
2869 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2870 break;
2871
2872 case 20:
2873 //lit + vflip
2874 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2875 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2876 break;
2877
2878 case 22:
2879 //Pivot, vflip, lit
2880 //return an error, cannot both rotate and pivot
2881 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2882 break;
2883
2884 case 24:
2885 //lit + h flip
2886 //return an error, cannot both rotate and H flip
2887 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
2888 break;
2889
2890 case 26:
2891 //pivot + lit + hflip
2892 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
2893 //return error cannot pivot, lit, and flip
2894 break;
2895
2896 case 28:
2897 //lit + vh flip
2898 //return an error, cannot both rotate and VH flip
2899 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2900 break;
2901
2902 case 32: //gouraud
2903 //Probably not wort supporting.
2904 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2905 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2906 break;
2907
2908 case 0:
2909 //no effect.
2910 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2911 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2912 break;
2913
2914 default:
2915 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2916
2917 }
2918 }
2919 } //end if stretched and masked
2920
2921 else //stretched, not masked
2922 {
2923 if ( rot == 0 ) //if not rotated
2924 {
2925 switch(mode) {
2926 case 1:
2927 //transparent
2928 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2929 draw_trans_sprite(bmp, subBmp, dx, dy);
2930 break;
2931
2932
2933 case 2:
2934 //pivot?
2935 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2936 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2937 //Pivoting requires two more args
2938 break;
2939
2940 case 3:
2941 //pivot + trans
2942 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2943 pivot_sprite_trans(bmp, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
2944 break;
2945
2946 case 4:
2947 //flip v
2948 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2949 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2950 break;
2951
2952 case 5:
2953 //trans + v flip
2954 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2955 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2956 break;
2957
2958 case 6:
2959 //pivot + v flip
2960 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2961 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2962 break;
2963
2964 case 8:
2965 //vlip h
2966 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2967 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2968 break;
2969
2970 case 9:
2971 //trans + h flip
2972 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2973 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2974 break;
2975
2976 case 10:
2977 //flip H and pivot
2978 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2979 //return error cannot pivot and h flip
2980 break;
2981
2982 case 12:
2983 //vh flip
2984 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2985 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2986 break;
2987
2988 case 13:
2989 //trans + vh flip
2990 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2991 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2992 break;
2993
2994 case 14:
2995 //pivot and vh flip
2996 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2997 //return error cannot both pivot and vh flip
2998 break;
2999
3000 case 16:
3001 //lit
3002 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3003 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3004 break;
3005
3006 case 18:
3007 //pivot, lit
3008 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3009 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3010 break;
3011
3012 case 20:
3013 //lit + v flip
3014 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3015 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3016 break;
3017
3018 case 22:
3019 //Pivot, vflip, lit
3020 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3021 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3022 break;
3023
3024 case 24:
3025 //lit + h flip
3026 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3027 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3028 break;
3029
3030 case 26:
3031 //pivot + lit + hflip
3032 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3033 //return error cannot pivot, lit, and flip
3034 break;
3035
3036 case 28:
3037 //lit + vh flip
3038 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3039 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3040 break;
3041
3042 case 32: //gouraud
3043 //Probably not wort supporting.
3044 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3045 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3046 break;
3047
3048 case 0:
3049 //no effect
3050 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
3051 break;
3052
3053
3054 default:
3055 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3056
3057
3058 }
3059 } //end if not rotated
3060
3061 if ( rot != 0 ) //if rotated
3062 {
3063 switch(mode)
3064 {
3065 case 1:
3066 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3067 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3068
3069 break;
3070
3071 case 2:
3072 //pivot?
3073 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3074 //return an error, cannot both rotate and pivot
3075 break;
3076
3077 case 3:
3078 //pivot + trans
3079 //return an error, cannot both rotate and pivot
3080 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3081 break;
3082
3083 case 4:
3084 //flip v
3085 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3086 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3087 break;
3088
3089 case 5:
3090 //trans + v flip
3091 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3092 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3093 break;
3094
3095 case 6:
3096 //pivot + v flip
3097 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3098 //return an error, cannot both rotate and pivot
3099 break;
3100
3101 case 8:
3102 //flip h
3103 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3104 //return an error, cannot both rotate and flip H
3105 break;
3106
3107 case 9:
3108 //trans + h flip
3109 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3110 //return an error, cannot rotate and flip a trans sprite
3111 break;
3112
3113 case 10:
3114 //flip H and pivot
3115 //return error cannot pivot and h flip
3116 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3117 break;
3118
3119 case 12:
3120 //vh flip
3121 //return an error, cannot rotate and VH flip a trans sprite
3122 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3123 break;
3124
3125 case 13:
3126 //trans + vh flip
3127 //return an error, cannot rotate and VH flip a trans sprite
3128 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3129 break;
3130
3131 case 14:
3132 //pivot and vh flip
3133 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3134 //return error cannot both pivot and vh flip
3135 break;
3136
3137 case 16:
3138 //lit
3139 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3140 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3141 break;
3142
3143 case 18:
3144 //pivot, lit
3145 //return an error, cannot both rotate and pivot
3146 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3147 break;
3148
3149 case 20:
3150 //lit + vflip
3151 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3152 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3153 break;
3154
3155 case 22:
3156 //Pivot, vflip, lit
3157 //return an error, cannot both rotate and pivot
3158 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3159 break;
3160
3161 case 24:
3162 //lit + h flip
3163 //return an error, cannot both rotate and H flip
3164 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3165 break;
3166
3167 case 26:
3168 //pivot + lit + hflip
3169 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3170 //return error cannot pivot, lit, and flip
3171 break;
3172
3173 case 28:
3174 //lit + vh flip
3175 //return an error, cannot both rotate and VH flip
3176 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3177 break;
3178
3179 case 32: //gouraud
3180 //Probably not wort supporting.
3181 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3182 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3183 break;
3184
3185 case 0:
3186 //no effect.
3187 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3188 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3189 break;
3190
3191 default:
3192 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3193
3194 }
3195 }
3196
3197 } //end if stretched, but not masked
3198 }
3199 else //not stretched
3200 {
3201
3202 if(masked) //if masked, but not stretched
3203 {
3204
3205 if ( rot == 0 ) //if not rotated
3206 {
3207 switch(mode)
3208 {
3209 case 1:
3210 //transparent
3211 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3212 draw_trans_sprite(bmp, subBmp, dx, dy);
3213 break;
3214
3215
3216 case 2:
3217 //pivot?
3218 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3219 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3220 //Pivoting requires two more args
3221 break;
3222
3223 case 3:
3224 //pivot + trans
3225 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3226 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3227 break;
3228
3229 case 4:
3230 //flip v
3231 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3232 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3233 break;
3234
3235 case 5:
3236 //trans + v flip
3237 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3238 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3239 break;
3240
3241 case 6:
3242 //pivot + v flip
3243 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3244 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3245 break;
3246
3247 case 8:
3248 //vlip h
3249 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3250 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3251 break;
3252
3253 case 9:
3254 //trans + h flip
3255 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3256 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3257 break;
3258
3259 case 10:
3260 //flip H and pivot
3261 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3262 //return error cannot pivot and h flip
3263 break;
3264
3265 case 12:
3266 //vh flip
3267 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3268 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3269 break;
3270
3271 case 13:
3272 //trans + vh flip
3273 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3274 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3275 break;
3276
3277 case 14:
3278 //pivot and vh flip
3279 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3280 //return error cannot both pivot and vh flip
3281 break;
3282
3283 case 16:
3284 //lit
3285 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3286 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3287 break;
3288
3289 case 18:
3290 //pivot, lit
3291 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3292 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3293 break;
3294
3295 case 20:
3296 //lit + v flip
3297 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3298 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3299 break;
3300
3301 case 22:
3302 //Pivot, vflip, lit
3303 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3304 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3305 break;
3306
3307 case 24:
3308 //lit + h flip
3309 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3310 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3311 break;
3312
3313 case 26:
3314 //pivot + lit + hflip
3315 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3316 //return error cannot pivot, lit, and flip
3317 break;
3318
3319 case 28:
3320 //lit + vh flip
3321 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3322 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3323 break;
3324
3325 case 32: //gouraud
3326 //Probably not wort supporting.
3327 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3328 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3329 break;
3330
3331 case 0:
3332 //no effect
3333 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3334 break;
3335
3336
3337 default:
3338 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3339
3340
3341 }
3342 } //end if not rotated
3343
3344 if ( rot != 0 ) //if rotated
3345 {
3346 switch(mode)
3347 {
3348 case 1:
3349 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //transparent
3350 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3351
3352 break;
3353
3354 case 2:
3355 //pivot?
3356 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3357 //return an error, cannot both rotate and pivot
3358 break;
3359
3360 case 3:
3361 //pivot + trans
3362 //return an error, cannot both rotate and pivot
3363 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3364 break;
3365
3366 case 4:
3367 //flip v
3368 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3369 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3370 break;
3371
3372 case 5:
3373 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
3374 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3375 break;
3376
3377 case 6:
3378 //pivot + v flip
3379 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3380 //return an error, cannot both rotate and pivot
3381 break;
3382
3383 case 8:
3384 //flip h
3385 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3386 //return an error, cannot both rotate and flip H
3387 break;
3388
3389 case 9:
3390 //trans + h flip
3391 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3392 //return an error, cannot rotate and flip a trans sprite
3393 break;
3394
3395 case 10:
3396 //flip H and pivot
3397 //return error cannot pivot and h flip
3398 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3399 break;
3400
3401 case 12:
3402 //vh flip
3403 //return an error, cannot rotate and VH flip a trans sprite
3404 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3405 break;
3406
3407 case 13:
3408 //trans + vh flip
3409 //return an error, cannot rotate and VH flip a trans sprite
3410 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3411 break;
3412
3413 case 14:
3414 //pivot and vh flip
3415 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3416 //return error cannot both pivot and vh flip
3417 break;
3418
3419 case 16:
3420 //lit
3421 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3422 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3423 break;
3424
3425 case 18:
3426 //pivot, lit
3427 //return an error, cannot both rotate and pivot
3428 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3429 break;
3430
3431 case 20:
3432 //lit + vflip
3433 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3434 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3435 break;
3436
3437 case 22:
3438 //Pivot, vflip, lit
3439 //return an error, cannot both rotate and pivot
3440 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3441 break;
3442
3443 case 24:
3444 //lit + h flip
3445 //return an error, cannot both rotate and H flip
3446 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3447 break;
3448
3449 case 26:
3450 //pivot + lit + hflip
3451 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3452 //return error cannot pivot, lit, and flip
3453 break;
3454
3455 case 28:
3456 //lit + vh flip
3457 //return an error, cannot both rotate and VH flip
3458 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3459 break;
3460
3461 case 32: //gouraud
3462 //Probably not wort supporting.
3463 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3464 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3465 break;
3466
3467 case 0:
3468 //no effect.
3469 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3470 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3471 break;
3472
3473 default:
3474 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3475
3476 }
3477 } //end rtated, masked
3478 } //end if masked
3479
3480 else //not masked, and not stretched; just blit
3481 {
3482
3483 if ( rot == 0 ) //if not rotated
3484 {
3485 switch(mode)
3486 {
3487 case 1:
3488 //transparent
3489 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3490 draw_trans_sprite(bmp, subBmp, dx, dy);
3491 break;
3492
3493
3494 case 2:
3495 //pivot?
3496 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3497 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3498 //Pivoting requires two more args
3499 break;
3500
3501 case 3:
3502 //pivot + trans
3503 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3504 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3505 break;
3506
3507 case 4:
3508 //flip v
3509 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3510 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3511 break;
3512
3513 case 5:
3514 //trans + v flip
3515 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3516 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3517 break;
3518
3519 case 6:
3520 //pivot + v flip
3521 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3522 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3523 break;
3524
3525 case 8:
3526 //vlip h
3527 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3528 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3529 break;
3530
3531 case 9:
3532 //trans + h flip
3533 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3534 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3535 break;
3536
3537 case 10:
3538 //flip H and pivot
3539 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3540 //return error cannot pivot and h flip
3541 break;
3542
3543 case 12:
3544 //vh flip
3545 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3546 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3547 break;
3548
3549 case 13:
3550 //trans + vh flip
3551 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3552 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3553 break;
3554
3555 case 14:
3556 //pivot and vh flip
3557 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3558 //return error cannot both pivot and vh flip
3559 break;
3560
3561 case 16:
3562 //lit
3563 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3564 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3565 break;
3566
3567 case 18:
3568 //pivot, lit
3569 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3570 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3571 break;
3572
3573 case 20:
3574 //lit + v flip
3575 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3576 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3577 break;
3578
3579 case 22:
3580 //Pivot, vflip, lit
3581 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3582 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3583 break;
3584
3585 case 24:
3586 //lit + h flip
3587 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3588 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3589 break;
3590
3591 case 26:
3592 //pivot + lit + hflip
3593 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3594 //return error cannot pivot, lit, and flip
3595 break;
3596
3597 case 28:
3598 //lit + vh flip
3599 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3600 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3601 break;
3602
3603 case 32: //gouraud
3604 //Probably not wort supporting.
3605 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3606 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3607 break;
3608
3609 case 0:
3610 //no effect
3611 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3612 break;
3613
3614
3615 default:
3616 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3617
3618
3619 }
3620 } //end if not rotated
3621
3622 if ( rot != 0 ) //if rotated
3623 {
3624 switch(mode)
3625 {
3626 case 1:
3627 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);//transparent
3628 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3629
3630 break;
3631
3632 case 2:
3633 //pivot?
3634 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3635 //return an error, cannot both rotate and pivot
3636 break;
3637
3638 case 3:
3639 //pivot + trans
3640 //return an error, cannot both rotate and pivot
3641 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3642 break;
3643
3644 case 4:
3645 //flip v
3646 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3647 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3648 break;
3649
3650 case 5:
3651 //trans + v flip
3652 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3653 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3654 break;
3655
3656 case 6:
3657 //pivot + v flip
3658 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3659 //return an error, cannot both rotate and pivot
3660 break;
3661
3662 case 8:
3663 //flip h
3664 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3665 //return an error, cannot both rotate and flip H
3666 break;
3667
3668 case 9:
3669 //trans + h flip
3670 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3671 //return an error, cannot rotate and flip a trans sprite
3672 break;
3673
3674 case 10:
3675 //flip H and pivot
3676 //return error cannot pivot and h flip
3677 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3678 break;
3679
3680 case 12:
3681 //vh flip
3682 //return an error, cannot rotate and VH flip a trans sprite
3683 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3684 break;
3685
3686 case 13:
3687 //trans + vh flip
3688 //return an error, cannot rotate and VH flip a trans sprite
3689 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3690 break;
3691
3692 case 14:
3693 //pivot and vh flip
3694 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3695 //return error cannot both pivot and vh flip
3696 break;
3697
3698 case 16:
3699 //lit
3700 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3701 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3702 break;
3703
3704 case 18:
3705 //pivot, lit
3706 //return an error, cannot both rotate and pivot
3707 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3708 break;
3709
3710 case 20:
3711 //lit + vflip
3712 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3713 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3714 break;
3715
3716 case 22:
3717 //Pivot, vflip, lit
3718 //return an error, cannot both rotate and pivot
3719 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3720 break;
3721
3722 case 24:
3723 //lit + h flip
3724 //return an error, cannot both rotate and H flip
3725 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3726 break;
3727
3728 case 26:
3729 //pivot + lit + hflip
3730 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3731 //return error cannot pivot, lit, and flip
3732 break;
3733
3734 case 28:
3735 //lit + vh flip
3736 //return an error, cannot both rotate and VH flip
3737 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3738 break;
3739
3740 case 32: //gouraud
3741 //Probably not wort supporting.
3742 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3743 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3744 break;
3745
3746 case 0:
3747 //no effect.
3748 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3749 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3750 break;
3751
3752 default:
3753 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3754
3755 }
3756 } //end if rotated
3757 } //end if not masked
3758 } //end if not stretched
3759
3760 //cleanup
3761 if(subBmp)
3762 {
3763 script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
3764 }
3765 }
3766
3767
3768 void do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3769 {
3770 //sdci[1]=layer
3771 //sdci[2]=pos[12]
3772 //sdci[3]=uv[8]
3773 //sdci[4]=color[4]
3774 //sdci[5]=size[2]
3775 //sdci[6]=flip
3776 //sdci[7]=tile/combo
3777 //sdci[8]=polytype
3778
3779 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3780
3781 if(!v_ptr)
3782 {
3783 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
3784 return;
3785 }
3786
3787 std::vector<int32_t> &v = *v_ptr;
3788
3789 if(v.empty())
3790 return;
3791
3792 int32_t* pos = &v[0];
3793 int32_t* uv = &v[12];
3794 int32_t* col = &v[20];
3795 int32_t* size = &v[24];
3796
3797 int32_t w = size[0]; //magic numerical constants... yuck.
3798 int32_t h = size[1];
3799 int32_t flip = (sdci[6]/10000)&3;
3800 int32_t tile = sdci[7]/10000;
3801 int32_t polytype = sdci[8]/10000;
3802
3803 polytype = vbound(polytype, 0, 14);
3804
3805 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3806 {
3807 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3808 return; //non power of two error
3809 }
3810
3811 int32_t tex_width = w*16;
3812 int32_t tex_height = h*16;
3813
3814 bool mustDestroyBmp = false;
3815 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3816
3817 if(!tex)
3818 {
3819 mustDestroyBmp = true;
3820 tex = create_bitmap_ex(8, tex_width, tex_height);
3821 clear_bitmap(tex);
3822 }
3823
3824 if(tile > 0) // TILE
3825 {
3826 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3827 }
3828 else // COMBO
3829 {
3830 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
3831 const int32_t tiletodraw = combo_tile(c, 0, 0);
3832 flip = flip ^ c.flip;
3833
3834 if(!(c.animflags & AF_EDITOR_ONLY))
3835 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3836 }
3837
3838 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3839 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3840 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3841 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
3842
3843 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
3844
3845 if(mustDestroyBmp)
3846 destroy_bitmap(tex);
3847
3848 }
3849
3850
3851
3852 void do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3853 {
3854 //sdci[1]=layer
3855 //sdci[2]=pos[9]
3856 //sdci[3]=uv[6]
3857 //sdci[4]=color[3]
3858 //sdci[5]=size[2]
3859 //sdci[6]=flip
3860 //sdci[7]=tile/combo
3861 //sdci[8]=polytype
3862
3863 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3864
3865 if(!v_ptr)
3866 {
3867 al_trace("Triange3d: Vector pointer is null! Internal error. \n");
3868 return;
3869 }
3870
3871 std::vector<int32_t> &v = *v_ptr;
3872
3873 if(v.empty())
3874 return;
3875
3876 int32_t* pos = &v[0];
3877 int32_t* uv = &v[9];
3878 int32_t* col = &v[15];
3879 int32_t* size = &v[18];
3880
3881 int32_t w = size[0]; //magic numerical constants... yuck.
3882 int32_t h = size[1];
3883 int32_t flip = (sdci[6]/10000)&3;
3884 int32_t tile = sdci[7]/10000;
3885 int32_t polytype = sdci[8]/10000;
3886
3887 polytype = vbound(polytype, 0, 14);
3888
3889 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3890 {
3891 Z_message("Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3892 return; //non power of two error
3893 }
3894
3895 int32_t tex_width = w*16;
3896 int32_t tex_height = h*16;
3897
3898 bool mustDestroyBmp = false;
3899 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3900
3901 if(!tex)
3902 {
3903 mustDestroyBmp = true;
3904 tex = create_bitmap_ex(8, tex_width, tex_height);
3905 clear_bitmap(tex);
3906 }
3907
3908 if(tile > 0) // TILE
3909 {
3910 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3911 }
3912 else // COMBO
3913 {
3914 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
3915 const int32_t tiletodraw = combo_tile(c, 0, 0);
3916 flip = flip ^ c.flip;
3917
3918 if(!(c.animflags & AF_EDITOR_ONLY))
3919 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3920 }
3921
3922 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3923 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3924 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3925
3926 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
3927
3928 if(mustDestroyBmp)
3929 destroy_bitmap(tex);
3930
3931 }
3932
3933 12431 void bmp_do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3934 {
3935 //Z_scripterrlog("rect sdci[13] is: %d\n", sdci[13]);
3936 //sdci[1]=layer
3937 //sdci[2]=x
3938 //sdci[3]=y
3939 //sdci[4]=x2
3940 //sdci[5]=y2
3941 //sdci[6]=color
3942 //sdci[7]=scale factor
3943 //sdci[8]=rotation anchor x
3944 //sdci[9]=rotation anchor y
3945 //sdci[10]=rotation angle
3946 //sdci[11]=fill
3947 //sdci[12]=opacity
3948 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
3949
1/2
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
12431 if(sdci[7]==0) //scale
3950 {
3951 return;
3952 }
3953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12431 times.
12431 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
3954 {
3955 Z_scripterrlog("bitmap->Rectangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
3956 return;
3957 }
3958 12431 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
3959
1/2
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
12431 if ( refbmp == NULL ) return;
3960
3961
2/4
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12431 times.
12431 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
3962
3963 12431 int32_t x1=sdci[2]/10000;
3964 12431 int32_t y1=sdci[3]/10000;
3965 12431 int32_t x2=sdci[4]/10000;
3966 12431 int32_t y2=sdci[5]/10000;
3967
3968
3969
2/2
✓ Branch 0 taken 12427 times.
✓ Branch 1 taken 4 times.
12431 if(x1>x2)
3970 {
3971 4 zc_swap(x1,x2);
3972 4 }
3973
3974
2/2
✓ Branch 0 taken 11147 times.
✓ Branch 1 taken 1284 times.
12431 if(y1>y2)
3975 {
3976 1284 zc_swap(y1,y2);
3977 1284 }
3978
3979
2/2
✓ Branch 0 taken 11151 times.
✓ Branch 1 taken 1280 times.
12431 if(sdci[7] != 10000)
3980 {
3981 1280 int32_t w=x2-x1+1;
3982 1280 int32_t h=y2-y1+1;
3983 1280 int32_t w2=(w*sdci[7])/10000;
3984 1280 int32_t h2=(h*sdci[7])/10000;
3985 1280 x1=x1-((w2-w)/2);
3986 1280 x2=x2+((w2-w)/2);
3987 1280 y1=y1-((h2-h)/2);
3988 1280 y2=y2+((h2-h)/2);
3989 1280 }
3990
3991 12431 int32_t color=sdci[6]/10000;
3992
3993
2/2
✓ Branch 0 taken 12303 times.
✓ Branch 1 taken 128 times.
12431 if(sdci[12]/10000<=127) //translucent
3994 {
3995 128 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
3996 128 }
3997
3998
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12335 times.
12431 if(sdci[10]==0) //no rotation
3999 {
4000
2/2
✓ Branch 0 taken 9143 times.
✓ Branch 1 taken 3192 times.
12335 if(sdci[11]) //filled
4001 {
4002 9143 rectfill(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
4003 9143 }
4004 else //outline
4005 {
4006 3192 rect(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
4007 }
4008 12335 }
4009 else //rotate
4010 {
4011 int32_t xy[16];
4012 96 int32_t rx=sdci[8]/10000;
4013 96 int32_t ry=sdci[9]/10000;
4014 96 fixed ra1=itofix(sdci[10]%10000)/10000;
4015 96 fixed ra2=itofix(sdci[10]/10000);
4016 96 fixed ra=ra1+ra2;
4017 96 ra = (ra/360)*256;
4018
4019 96 fixed fcosa = fixcos(ra);
4020 96 fixed fsina = fixsin(ra);
4021
4022 96 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
4023 96 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
4024 96 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
4025 96 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
4026 96 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
4027 96 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
4028 96 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
4029 96 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
4030 96 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
4031 96 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
4032 96 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
4033 96 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
4034 96 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
4035 96 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
4036 96 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
4037 96 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
4038
4039
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(sdci[11]) //filled
4040 {
4041 96 polygon(refbmp, 4, xy, color);
4042 96 }
4043 else //outline
4044 {
4045 line(refbmp, xy[0], xy[1], xy[10], xy[11], color);
4046 line(refbmp, xy[2], xy[3], xy[12], xy[13], color);
4047 line(refbmp, xy[4], xy[5], xy[14], xy[15], color);
4048 line(refbmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
4049 }
4050 }
4051
4052 12431 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4053 12431 }
4054
4055 void bmp_do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4056 {
4057 //sdci[1]=layer
4058 //sdci[2]=x
4059 //sdci[3]=y
4060 //sdci[4]=tile
4061 //sdci[5]=cset
4062 //sdci[6]=width
4063 //sdci[7]=height
4064 //sdci[8]=overlay
4065 //sdci[9]=opacity
4066
4067 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4068 {
4069 Z_scripterrlog("bitmap->DrawFrame() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4070 return;
4071 }
4072 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4073 if ( refbmp == NULL ) return;
4074
4075 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4076
4077 int32_t x=sdci[2]/10000;
4078 int32_t y=sdci[3]/10000;
4079
4080 int32_t tile=sdci[4]/10000;
4081 int32_t cs=sdci[5]/10000;
4082 int32_t w=sdci[6]/10000;
4083 int32_t h=sdci[7]/10000;
4084 bool overlay=sdci[8];
4085 bool trans=(sdci[9]/10000<=127);
4086
4087 frame2x2(refbmp, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
4088 }
4089
4090
4091 192290 void bmp_do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4092 {
4093 //sdci[1]=layer
4094 //sdci[2]=x
4095 //sdci[3]=y
4096 //sdci[4]=radius
4097 //sdci[5]=color
4098 //sdci[6]=scale factor
4099 //sdci[7]=rotation anchor x
4100 //sdci[8]=rotation anchor y
4101 //sdci[9]=rotation angle
4102 //sdci[10]=fill
4103 //sdci[11]=opacity
4104 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4105
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[6]==0) //scale
4106 {
4107 return;
4108 }
4109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192290 times.
192290 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4110 {
4111 Z_scripterrlog("bitmap->Circle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4112 return;
4113 }
4114 192290 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4115
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if ( refbmp == NULL ) return;
4116
4117
2/4
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192290 times.
192290 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4118
4119 192290 int32_t x1=sdci[2]/10000;
4120 192290 int32_t y1=sdci[3]/10000;
4121 192290 qword r=sdci[4];
4122
4123
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[6] != 10000)
4124 {
4125 r*=sdci[6];
4126 r/=10000;
4127 }
4128
4129 192290 r/=10000;
4130 192290 int32_t color=sdci[5]/10000;
4131
4132
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[11]/10000<=127) //translucent
4133 {
4134 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4135 }
4136
4137
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 192290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
192290 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
4138 {
4139 int32_t xy[2];
4140 int32_t rx=sdci[7]/10000;
4141 int32_t ry=sdci[8]/10000;
4142 fixed ra1=itofix(sdci[9]%10000)/10000;
4143 fixed ra2=itofix(sdci[9]/10000);
4144 fixed ra=ra1+ra2;
4145 ra = (ra/360)*256;
4146
4147 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4148 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4149 x1=xy[0];
4150 y1=xy[1];
4151 }
4152
4153
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[10]) //filled
4154 {
4155 192290 circlefill(refbmp, x1+xoffset, y1+yoffset, r, color);
4156 192290 }
4157 else //outline
4158 {
4159 circle(refbmp, x1+xoffset, y1+yoffset, r, color);
4160 }
4161
4162 192290 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4163 192290 }
4164
4165
4166 void bmp_do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4167 {
4168 //sdci[1]=layer
4169 //sdci[2]=x
4170 //sdci[3]=y
4171 //sdci[4]=radius
4172 //sdci[5]=start angle
4173 //sdci[6]=end angle
4174 //sdci[7]=color
4175 //sdci[8]=scale factor
4176 //sdci[9]=rotation anchor x
4177 //sdci[10]=rotation anchor y
4178 //sdci[11]=rotation angle
4179 //sdci[12]=closed
4180 //sdci[13]=fill
4181 //sdci[14]=opacity
4182 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4183
4184 if(sdci[8]==0) //scale
4185 {
4186 return;
4187 }
4188 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4189 {
4190 Z_scripterrlog("bitmap->Arc() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4191 return;
4192 }
4193 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4194 if ( refbmp == NULL ) return;
4195
4196 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4197
4198 int32_t cx=sdci[2]/10000;
4199 int32_t cy=sdci[3]/10000;
4200 qword r=sdci[4];
4201
4202 if(sdci[8] != 10000)
4203 {
4204 r*=sdci[8];
4205 r/=10000;
4206 }
4207
4208 r/=10000;
4209
4210 int32_t color=sdci[7]/10000;
4211
4212 fixed ra1=itofix(sdci[11]%10000)/10000;
4213 fixed ra2=itofix(sdci[11]/10000);
4214 fixed ra=ra1+ra2;
4215 ra = (ra/360)*256;
4216
4217
4218 fixed a1=itofix(sdci[5]%10000)/10000;
4219 fixed a2=itofix(sdci[5]/10000);
4220 fixed sa=a1+a2;
4221 sa = (sa/360)*256;
4222
4223 a1=itofix(sdci[6]%10000)/10000;
4224 a2=itofix(sdci[6]/10000);
4225 fixed ea=a1+a2;
4226 ea = (ea/360)*256;
4227
4228 if(sdci[11]!=0) //rotation
4229 {
4230 int32_t rx=sdci[9]/10000;
4231 int32_t ry=sdci[10]/10000;
4232
4233 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
4234 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
4235 ea-=ra;
4236 sa-=ra;
4237 }
4238
4239 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
4240 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
4241
4242 if(sdci[12]) //closed
4243 {
4244 if(sdci[13]) //filled
4245 {
4246 clear_bitmap(prim_bmp);
4247 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4248 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4249 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4250 int fillx = zc_max(0,fx)+xoffset;
4251 int filly = zc_max(0,fy)+yoffset;
4252 zprint2("bitmap->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
4253 floodfill(prim_bmp, fillx, filly, color);
4254
4255 if(sdci[14]/10000<=127) //translucent
4256 {
4257 draw_trans_sprite(refbmp, prim_bmp, 0,0);
4258 }
4259 else
4260 {
4261 draw_sprite(refbmp, prim_bmp, 0,0);
4262 }
4263 }
4264 else
4265 {
4266 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4267 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4268 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4269 }
4270 }
4271 else
4272 {
4273 if(sdci[14]/10000<=127) //translucent
4274 {
4275 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4276 }
4277
4278 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4279 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4280 }
4281 }
4282
4283
4284 502 void bmp_do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4285 {
4286 //sdci[1]=layer
4287 //sdci[2]=x
4288 //sdci[3]=y
4289 //sdci[4]=radiusx
4290 //sdci[5]=radiusy
4291 //sdci[6]=color
4292 //sdci[7]=scale factor
4293 //sdci[8]=rotation anchor x
4294 //sdci[9]=rotation anchor y
4295 //sdci[10]=rotation angle
4296 //sdci[11]=fill
4297 //sdci[12]=opacity
4298 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4299
4300
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if(sdci[7]==0) //scale
4301 {
4302 return;
4303 }
4304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 502 times.
502 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4305 {
4306 Z_scripterrlog("bitmap->Ellipse() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4307 return;
4308 }
4309 502 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4310
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if ( refbmp == NULL ) return;
4311
4312 502 int32_t x1=sdci[2]/10000;
4313 502 int32_t y1=sdci[3]/10000;
4314 502 int32_t radx=sdci[4]/10000;
4315 502 radx*=sdci[7]/10000;
4316 502 int32_t rady=sdci[5]/10000;
4317 502 rady*=sdci[7]/10000;
4318 502 int32_t color=sdci[6]/10000;
4319 502 float rotation = sdci[10]/10000;
4320
4321 502 int32_t rx=sdci[8]/10000;
4322 502 int32_t ry=sdci[9]/10000;
4323 502 fixed ra1=itofix(sdci[10]%10000)/10000;
4324 502 fixed ra2=itofix(sdci[10]/10000);
4325 502 fixed ra=ra1+ra2;
4326 502 ra = (ra/360)*256;
4327
4328
2/4
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 502 times.
✗ Branch 3 not taken.
502 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4329
4330 int32_t xy[2];
4331 502 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4332 502 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4333 502 x1=xy[0];
4334 502 y1=xy[1];
4335
4336
6/8
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 494 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 494 times.
502 if(radx<1||rady<1||radx>255||rady>255) return;
4337
4338 494 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
4339
4340
2/4
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 494 times.
494 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4341
4342
1/2
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
494 if(sdci[11]) //filled
4343 {
4344
4345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494 times.
494 if(sdci[12]/10000<128) //translucent
4346 {
4347 clear_bitmap(prim_bmp);
4348 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4349 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4350 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4351 }
4352 else // no opacity
4353 {
4354
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4355 494 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4356 }
4357 494 }
4358 else //not filled
4359 {
4360 if(sdci[12]/10000<128) //translucent
4361 {
4362 clear_bitmap(prim_bmp);
4363 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4364 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4365 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4366 }
4367 else // no opacity
4368 {
4369 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4370 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4371 }
4372 }
4373
4374 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
4375 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
4376 // the ellipse, but it shouldn't be used anyway.
4377
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 if(color==0)
4378 {
4379 // This is very slow, so check the smallest possible square
4380
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
4381
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
4382
4383
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 4430 times.
✓ Branch 7 taken 62 times.
4492 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
4384
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4430 times.
✓ Branch 2 taken 1086 times.
✓ Branch 3 taken 3344 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1086 times.
✓ Branch 6 taken 467774 times.
✓ Branch 7 taken 4430 times.
472204 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
4385
2/2
✓ Branch 0 taken 238992 times.
✓ Branch 1 taken 228782 times.
696556 if(getpixel(refbmp, x, y)==255)
4386 233212 putpixel(refbmp, x, y, 0);
4387 62 }
4388
4389 494 script_drawing_commands.ReleaseSubBitmap(bitty);
4390 502 }
4391
4392
4393 144 void bmp_do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4394 {
4395 //sdci[1]=layer
4396 //sdci[2]=x
4397 //sdci[3]=y
4398 //sdci[4]=x2
4399 //sdci[5]=y2
4400 //sdci[6]=color
4401 //sdci[7]=scale factor
4402 //sdci[8]=rotation anchor x
4403 //sdci[9]=rotation anchor y
4404 //sdci[10]=rotation angle
4405 //sdci[11]=opacity
4406 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4407
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7]==0) //scale
4408 {
4409 return;
4410 }
4411
4412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4413 {
4414 Z_scripterrlog("bitmap->Line() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4415 return;
4416 }
4417
4418 144 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4419
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if ( refbmp == NULL ) return;
4420
4421 144 int32_t x1=sdci[2]/10000;
4422 144 int32_t y1=sdci[3]/10000;
4423 144 int32_t x2=sdci[4]/10000;
4424 144 int32_t y2=sdci[5]/10000;
4425
4426
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7] != 10000)
4427 {
4428 int32_t w=x2-x1+1;
4429 int32_t h=y2-y1+1;
4430 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
4431 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
4432 x1=x1-((w2-w)/2);
4433 x2=x2+((w2-w)/2);
4434 y1=y1-((h2-h)/2);
4435 y2=y2+((h2-h)/2);
4436 }
4437
4438 144 int32_t color=sdci[6]/10000;
4439
4440
2/4
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
144 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4441
4442
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[11]/10000<=127) //translucent
4443 {
4444 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4445 }
4446
4447
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[10]!=0) //rotation
4448 {
4449 int32_t xy[4];
4450 int32_t rx=sdci[8]/10000;
4451 int32_t ry=sdci[9]/10000;
4452 fixed ra1=itofix(sdci[10]%10000)/10000;
4453 fixed ra2=itofix(sdci[10]/10000);
4454 fixed ra=ra1+ra2;
4455
4456 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4457 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4458 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
4459 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
4460 x1=xy[0];
4461 y1=xy[1];
4462 x2=xy[2];
4463 y2=xy[3];
4464 }
4465
4466 144 line(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
4467 144 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4468 144 }
4469
4470
4471 void bmp_do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4472 {
4473 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
4474 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4475
4476 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
4477 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
4478 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
4479 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
4480 };
4481
4482 if(sdci[11]/10000 < 128) //translucent
4483 {
4484 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4485 }
4486
4487 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4488 {
4489 Z_scripterrlog("bitmap->Spline() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4490 return;
4491 }
4492
4493 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4494 if ( refbmp == NULL ) return;
4495
4496 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4497
4498 spline(refbmp, points, sdci[10]/10000);
4499
4500 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4501 }
4502
4503
4504 80910 void bmp_do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4505 {
4506 //sdci[1]=layer
4507 //sdci[2]=x
4508 //sdci[3]=y
4509 //sdci[4]=color
4510 //sdci[5]=rotation anchor x
4511 //sdci[6]=rotation anchor y
4512 //sdci[7]=rotation angle
4513 //sdci[8]=opacity
4514 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4515 80910 int32_t x1=sdci[2]/10000;
4516 80910 int32_t y1=sdci[3]/10000;
4517 80910 int32_t color=sdci[4]/10000;
4518
4519
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if(sdci[8]/10000<=127) //translucent
4520 {
4521 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4522 }
4523
4524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4525 {
4526 Z_scripterrlog("bitmap->PutPixel() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4527 return;
4528 }
4529
4530 80910 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4531
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if ( refbmp == NULL ) return;
4532
4533
2/4
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80910 times.
✗ Branch 3 not taken.
80910 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4534
4535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if(sdci[7]!=0) //rotation
4536 {
4537 int32_t xy[2];
4538 int32_t rx=sdci[5]/10000;
4539 int32_t ry=sdci[6]/10000;
4540 fixed ra1=itofix(sdci[7]%10000)/10000;
4541 fixed ra2=itofix(sdci[7]/10000);
4542 fixed ra=ra1+ra2;
4543
4544 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4545 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4546 x1=xy[0];
4547 y1=xy[1];
4548 }
4549
4550 80910 putpixel(refbmp, x1+xoffset, y1+yoffset, color);
4551 80910 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4552 80910 }
4553
4554
4555 64994 void bmp_do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4556 {
4557 //sdci[1]=layer
4558 //sdci[2]=x
4559 //sdci[3]=y
4560 //sdci[4]=tile
4561 //sdci[5]=tile width
4562 //sdci[6]=tile height
4563 //sdci[7]=color (cset)
4564 //sdci[8]=scale x
4565 //sdci[9]=scale y
4566 //sdci[10]=rotation anchor x
4567 //sdci[11]=rotation anchor y
4568 //sdci[12]=rotation angle
4569 //sdci[13]=flip
4570 //sdci[14]=transparency
4571 //sdci[15]=opacity
4572 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4573
4574 64994 int32_t w = sdci[5]/10000;
4575 64994 int32_t h = sdci[6]/10000;
4576
4577
4/8
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64994 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64994 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 64994 times.
64994 if(w < 1 || h < 1 || h > 20 || w > 20)
4578 {
4579 return;
4580 }
4581
4582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64994 times.
64994 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4583 {
4584 Z_scripterrlog("bitmap->DrawTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4585 return;
4586 }
4587
4588 64994 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64994 times.
64994 if ( refbmp == NULL ) return;
4590
4591 64994 int32_t xscale=sdci[8]/10000;
4592 64994 int32_t yscale=sdci[9]/10000;
4593 64994 int32_t rx = sdci[10]/10000;
4594 64994 int32_t ry = sdci[11]/10000;
4595 64994 float rotation=sdci[12]/10000;
4596 64994 int32_t flip=(sdci[13]/10000)&3;
4597 64994 bool transparency=sdci[14]!=0;
4598 64994 int32_t opacity=sdci[15]/10000;
4599 64994 int32_t color=sdci[7]/10000;
4600
4601 64994 int32_t x1=sdci[2]/10000;
4602 64994 int32_t y1=sdci[3]/10000;
4603
4604
4605 //don't scale if it's not safe to do so
4606 64994 bool canscale = true;
4607
4608
2/4
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64994 times.
64994 if(xscale==0||yscale==0)
4609 {
4610 return;
4611 }
4612
4613
3/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 64088 times.
✓ Branch 2 taken 906 times.
✗ Branch 3 not taken.
64994 if(xscale<0||yscale<0)
4614 64088 canscale = false; //default size
4615
4616
2/4
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64994 times.
64994 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4617
4618
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 64088 times.
✓ Branch 2 taken 5644 times.
✓ Branch 3 taken 58444 times.
64994 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4619 {
4620 6550 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
4621
4622
1/2
✓ Branch 0 taken 6550 times.
✗ Branch 1 not taken.
6550 if(transparency) //transparency
4623 {
4624 6550 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
4625 6550 }
4626 else //no transparency
4627 {
4628 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
4629 }
4630
4631
2/2
✓ Branch 0 taken 5644 times.
✓ Branch 1 taken 906 times.
6550 if(rotation != 0)
4632 {
4633 //low negative values indicate no anchor-point rotation
4634
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5644 if(rx>-777||ry>-777)
4635 {
4636 int32_t xy[2];
4637 5644 fixed ra1=itofix(sdci[12]%10000)/10000;
4638 5644 fixed ra2=itofix(sdci[12]/10000);
4639 5644 fixed ra=ra1+ra2;
4640 5644 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4641 5644 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4642 5644 x1=xy[0];
4643 5644 y1=xy[1];
4644 5644 }
4645
4646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
5644 if(canscale) //scale first
4647 {
4648 //damnit all, .. fixme.
4649 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4650 clear_bitmap(tempbit);
4651
4652 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4653
4654 if(opacity < 128)
4655 {
4656 clear_bitmap(prim_bmp);
4657 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4658 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
4659 }
4660 else
4661 {
4662 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4663 }
4664
4665 destroy_bitmap(tempbit);
4666 }
4667 else //no scale
4668 {
4669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
5644 if(opacity < 128)
4670 {
4671 clear_bitmap(prim_bmp);
4672 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4673 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4674 }
4675 else
4676 {
4677 5644 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4678 }
4679 }
4680 5644 }
4681 else //scale only
4682 {
4683
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if(canscale)
4684 {
4685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(opacity<128)
4686 {
4687 clear_bitmap(prim_bmp);
4688 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4689 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4690 }
4691 else
4692 {
4693 906 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4694 }
4695 906 }
4696 else //error -do not scale
4697 {
4698 if(opacity<128)
4699 {
4700 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4701 }
4702 else
4703 {
4704 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4705 }
4706 }
4707 }
4708
4709 6550 script_drawing_commands.ReleaseSubBitmap(pbitty);
4710
4711 6550 }
4712 else // no scale or rotation
4713 {
4714
2/2
✓ Branch 0 taken 50106 times.
✓ Branch 1 taken 8338 times.
58444 if(transparency)
4715 {
4716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50106 times.
50106 if(opacity<=127)
4717 TileHelper::OverTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
4718 else
4719 50106 TileHelper::OverTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
4720 50106 }
4721 else
4722 {
4723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8338 times.
8338 if(opacity<=127)
4724 TileHelper::PutTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
4725 else
4726 8338 TileHelper::OldPutTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
4727 }
4728 }
4729 64994 }
4730
4731 void bmp_do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4732 {
4733 //sdci[1]=layer
4734 //sdci[2]=x
4735 //sdci[3]=y
4736 //sdci[4]=tile
4737 //sdci[5]=tile width
4738 //sdci[6]=tile height
4739 //sdci[7]=flip
4740 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4741
4742 int32_t w = sdci[5]/10000;
4743 int32_t h = sdci[6]/10000;
4744
4745 if(w < 1 || h < 1 || h > 20 || w > 20)
4746 {
4747 return;
4748 }
4749
4750 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4751 {
4752 Z_scripterrlog("bitmap->DrawTileCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4753 return;
4754 }
4755
4756 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4757 if ( refbmp == NULL ) return;
4758
4759 int32_t flip=(sdci[7]/10000)&3;
4760
4761 int32_t x1=sdci[2]/10000;
4762 int32_t y1=sdci[3]/10000;
4763
4764 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4765
4766 TileHelper::OverTileCloaked(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip);
4767 }
4768
4769
4770 11288 void bmp_do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4771 {
4772 //sdci[1]=layer
4773 //sdci[2]=x
4774 //sdci[3]=y
4775 //sdci[4]=combo
4776 //sdci[5]=tile width
4777 //sdci[6]=tile height
4778 //sdci[7]=color (cset)
4779 //sdci[8]=scale x
4780 //sdci[9]=scale y
4781 //sdci[10]=rotation anchor x
4782 //sdci[11]=rotation anchor y
4783 //sdci[12]=rotation angle
4784 //sdci[13]=frame
4785 //sdci[14]=flip
4786 //sdci[15]=transparency
4787 //sdci[16]=opacity
4788 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4789 11288 int32_t w = sdci[5]/10000;
4790 11288 int32_t h = sdci[6]/10000;
4791
4792
4/8
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11288 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11288 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11288 times.
11288 if(w<1||h<1||h>20||w>20)
4793 {
4794 return;
4795 }
4796
4797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4798 {
4799 Z_scripterrlog("bitmap->DrawCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4800 return;
4801 }
4802
4803 11288 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4804
1/2
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
11288 if ( refbmp == NULL ) return;
4805 11288 int32_t cmb = (sdci[4]/10000);
4806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if((unsigned)cmb >= MAXCOMBOS)
4807 {
4808 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4809 return;
4810 }
4811
4812 11288 int32_t xscale=sdci[8]/10000;
4813 11288 int32_t yscale=sdci[9]/10000;
4814 11288 int32_t rx = sdci[10]/10000; //these work now
4815 11288 int32_t ry = sdci[11]/10000; //these work now
4816 11288 float rotation=sdci[12]/10000;
4817
4818 11288 bool transparency=sdci[15]!=0;
4819 11288 int32_t opacity=sdci[16]/10000;
4820 11288 int32_t color=sdci[7]/10000;
4821 11288 int32_t x1=sdci[2]/10000;
4822 11288 int32_t y1=sdci[3]/10000;
4823
4824 11288 auto& c = GET_DRAWING_COMBO(cmb);
4825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if(c.animflags & AF_EDITOR_ONLY) return;
4826 11288 int32_t tiletodraw = combo_tile(c, x1, y1);
4827 11288 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
4828 11288 int32_t skiprows=c.skipanimy;
4829
4830
4831 //don't scale if it's not safe to do so
4832 11288 bool canscale = true;
4833
4834
2/4
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if(xscale==0||yscale==0)
4835 {
4836 return;
4837 }
4838
4839
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11288 if(xscale<0||yscale<0)
4840 11288 canscale = false; //default size
4841
4842
2/4
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4843
4844
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4845 {
4846 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
4847
4848 if(transparency)
4849 {
4850 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4851 }
4852 else //no transparency
4853 {
4854 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4855 }
4856
4857 if(rotation != 0) // rotate
4858 {
4859 //fixed point sucks ;0
4860 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
4861 {
4862 int32_t xy[2];
4863 fixed ra1=itofix(sdci[12]%10000)/10000;
4864 fixed ra2=itofix(sdci[12]/10000);
4865 fixed ra=ra1+ra2;
4866 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4867 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4868 x1=xy[0];
4869 y1=xy[1];
4870 }
4871
4872 if(canscale) //scale first
4873 {
4874 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4875 clear_bitmap(tempbit);
4876
4877 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4878
4879 if(opacity < 128)
4880 {
4881 clear_bitmap(prim_bmp);
4882 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4883 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4884 }
4885 else
4886 {
4887 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4888 }
4889
4890 destroy_bitmap(tempbit);
4891 }
4892 else //no scale
4893 {
4894 if(opacity < 128)
4895 {
4896 clear_bitmap(prim_bmp);
4897 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4898 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4899 }
4900 else
4901 {
4902 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4903 }
4904 }
4905 }
4906 else //scale only
4907 {
4908 if(canscale)
4909 {
4910 if(opacity<128)
4911 {
4912 clear_bitmap(prim_bmp);
4913 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4914 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4915 }
4916 else
4917 {
4918 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4919 }
4920 }
4921 else //error -do not scale
4922 {
4923 if(opacity<128)
4924 {
4925 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4926 }
4927 else
4928 {
4929 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4930 }
4931 }
4932 }
4933
4934 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
4935 }
4936 else // no scale or rotation
4937 {
4938
1/2
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
11288 if(transparency)
4939 {
4940
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 11006 times.
11288 if(opacity<=127)
4941 282 TileHelper::OverTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4942 else
4943 11006 TileHelper::OverTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4944 11288 }
4945 else
4946 {
4947 if(opacity<=127)
4948 TileHelper::PutTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4949 else
4950 TileHelper::OldPutTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4951 }
4952 }
4953 11288 }
4954
4955
4956 void bmp_do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4957 {
4958 //sdci[1]=layer
4959 //sdci[2]=x
4960 //sdci[3]=y
4961 //sdci[4]=combo
4962 //sdci[5]=tile width
4963 //sdci[6]=tile height
4964 //sdci[7]=flip
4965 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4966
4967 int32_t w = sdci[5]/10000;
4968 int32_t h = sdci[6]/10000;
4969
4970 if(w<1||h<1||h>20||w>20)
4971 {
4972 return;
4973 }
4974
4975 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4976 {
4977 Z_scripterrlog("bitmap->DrawComboCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4978 return;
4979 }
4980
4981 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4982 if ( refbmp == NULL ) return;
4983 int32_t cmb = (sdci[4]/10000);
4984 if((unsigned)cmb >= MAXCOMBOS)
4985 {
4986 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4987 return;
4988 }
4989
4990 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4991
4992 int32_t x1=sdci[2]/10000;
4993 int32_t y1=sdci[3]/10000;
4994
4995 auto& c = GET_DRAWING_COMBO(cmb);
4996 if(c.animflags & AF_EDITOR_ONLY) return;
4997 int32_t tiletodraw = combo_tile(c, x1, y1);
4998 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
4999 int32_t skiprows=c.skipanimy;
5000
5001 TileHelper::OverTileCloaked(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
5002 }
5003
5004
5005 1982263 void bmp_do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5006 {
5007 /* layer, x, y, tile, color opacity */
5008 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5009
5010 1982263 int32_t opacity = sdci[6]/10000;
5011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1982263 times.
1982263 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5012 {
5013 Z_scripterrlog("bitmap->FastTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5014 return;
5015 }
5016 1982263 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5017
1/2
✓ Branch 0 taken 1982263 times.
✗ Branch 1 not taken.
1982263 if ( refbmp == NULL ) return;
5018
5019
2/4
✓ Branch 0 taken 1982263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1982263 times.
✗ Branch 3 not taken.
1982263 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5020
5021 1982263 int x = xoffset+(sdci[2]/10000);
5022 1982263 int y = yoffset+(sdci[3]/10000);
5023
5024
2/2
✓ Branch 0 taken 29119 times.
✓ Branch 1 taken 1953144 times.
1982263 if(opacity < 128)
5025 29119 overtiletranslucent16(refbmp, sdci[4]/10000, x, y, sdci[5]/10000, 0, opacity);
5026 else
5027 1953144 overtile16(refbmp, sdci[4]/10000, x, y, sdci[5]/10000, 0);
5028 1982263 }
5029
5030 19821648 void do_bmpwritetile(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5031 {
5032 /* layer, x, y, tile, is8bit, mask */
5033 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19821648 times.
19821648 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5035 {
5036 Z_scripterrlog("bitmap->WriteTile() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5037 return;
5038 }
5039 19821648 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5040
1/2
✓ Branch 0 taken 19821648 times.
✗ Branch 1 not taken.
19821648 if ( refbmp == NULL ) return;
5041
5042
2/4
✓ Branch 0 taken 19821648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19821648 times.
✗ Branch 3 not taken.
19821648 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5043
5044 19821648 int32_t x = (sdci[2]/10000), y = (sdci[3]/10000), tl = (sdci[4]/10000);
5045 19821648 bool is8bit = sdci[5]!=0, mask = sdci[6]!=0;
5046
5047 19821648 write_tile(newtilebuf, refbmp, tl, x+xoffset, y+yoffset, is8bit, mask);
5048 19821648 }
5049
5050 void do_bmpdither(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5051 {
5052 /* layer, mask, color, ditherType, ditherArg */
5053 //sdci[2] Mask Bitmap Pointer
5054 //sdci[3] Color
5055 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5056 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5057 {
5058 Z_scripterrlog("bitmap->Dither() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5059 return;
5060 }
5061 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5062 if ( refbmp == NULL ) return;
5063 if ( sdci[2] <= 0 )
5064 {
5065 Z_scripterrlog("bitmap->Dither() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5066 return;
5067 }
5068 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5069 if ( mask == NULL ) return;
5070
5071 int32_t dType = sdci[4] / 10000L;
5072 if(dType < 0 || dType >= dithMax)
5073 {
5074 Z_scripterrlog("bitmap->Dither() used an invalid dither type: %d. Aborting.\n", dType);
5075 return;
5076 }
5077
5078 ditherblit(refbmp, mask, byte(sdci[3]/10000L), dType, sdci[5]/10000L);
5079 }
5080
5081 7323 void do_bmpreplcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5082 {
5083 /* layer, shift, startcol, endcol */
5084 //sdci[2] NewCol
5085 //sdci[3] StartCol
5086 //sdci[4] EndCol
5087 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7323 times.
7323 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5089 {
5090 Z_scripterrlog("bitmap->ReplaceColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5091 return;
5092 }
5093 7323 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7323 times.
7323 if ( refbmp == NULL ) return;
5095 7323 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, false);
5096 7323 }
5097
5098 void do_bmpshiftcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5099 {
5100 /* layer, shift, startcol, endcol */
5101 //sdci[2] ShiftAmount
5102 //sdci[3] StartCol
5103 //sdci[4] EndCol
5104 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5105 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5106 {
5107 Z_scripterrlog("bitmap->ShiftColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5108 return;
5109 }
5110 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5111 if ( refbmp == NULL ) return;
5112 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, true);
5113 }
5114
5115 906 void do_bmpmaskdraw(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5116 {
5117 /* layer, mask, color */
5118 //sdci[2] Mask Bitmap Pointer
5119 //sdci[3] Color
5120 //sdci[4] start mask color
5121 //sdci[5] end mask color
5122 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5123 906 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5124
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( refbmp == NULL )
5125 {
5126 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5127 return;
5128 }
5129 906 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5130
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( mask == NULL )
5131 {
5132 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5133 return;
5134 }
5135 906 auto fillcol = sdci[3]/10000L;
5136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(unsigned(fillcol) > 0xFF) return; //invalid color, nothing to draw
5137 906 auto startcol = vbound(sdci[4]/10000L,0x00,0xFF);
5138 906 auto endcol = vbound(sdci[5]/10000L,0x00,0xFF);
5139 906 mask_colorfill(refbmp, mask, fillcol, startcol, endcol);
5140 906 }
5141
5142 void do_bmpmaskblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5143 {
5144 /* layer, mask, color */
5145 //sdci[2] Mask Bitmap Pointer
5146 //sdci[3] Pattern Bitmap
5147 //sdci[4] bool 'pattern repeats'
5148 //sdci[5] start mask color
5149 //sdci[6] end mask color
5150 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5151 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5152 if ( refbmp == NULL )
5153 {
5154 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5155 return;
5156 }
5157 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5158 if ( mask == NULL )
5159 {
5160 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (mask) id: %d. Aborting.\n", sdci[2]);
5161 return;
5162 }
5163 BITMAP *pattern = resolveScriptingBitmap(sdci[3]);
5164 if ( pattern == NULL )
5165 {
5166 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (pattern) id: %d. Aborting.\n", sdci[3]);
5167 return;
5168 }
5169 bool repeats = sdci[4]!=0;
5170 auto startcol = vbound(sdci[5]/10000L,0x00,0xFF);
5171 auto endcol = vbound(sdci[6]/10000L,0x00,0xFF);
5172 mask_blit(refbmp, mask, pattern, repeats, startcol, endcol);
5173 }
5174
5175 40175665 void bmp_do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5176 {
5177 /* layer, x, y, tile, color opacity */
5178 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5179 40175665 int32_t opacity = sdci[6] / 10000;
5180 40175665 int32_t x1 = sdci[2] / 10000;
5181 40175665 int32_t y1 = sdci[3] / 10000;
5182 40175665 int32_t index = sdci[4]/10000;
5183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5184 {
5185 Z_scripterrlog("bitmap->FastCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5186 return;
5187 }
5188 40175665 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5189
1/2
✓ Branch 0 taken 40175665 times.
✗ Branch 1 not taken.
40175665 if ( refbmp == NULL ) return;
5190 40175665 int32_t cmb = (sdci[4]/10000);
5191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if((unsigned)cmb >= MAXCOMBOS)
5192 {
5193 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
5194 return;
5195 }
5196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if(combobuf[cmb].animflags & AF_EDITOR_ONLY) return;
5197
5198
2/4
✓ Branch 0 taken 40175665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40175665 times.
✗ Branch 3 not taken.
40175665 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5199
5200 40175665 int x = xoffset+x1;
5201 40175665 int y = yoffset+y1;
5202
5203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if(opacity < 128)
5204 {
5205 overcomboblocktranslucent(refbmp, x, y, cmb, sdci[5]/10000, 1, 1, 128);
5206
5207 }
5208 else
5209 {
5210 40175665 overcomboblock(refbmp, x, y, cmb, sdci[5]/10000, 1, 1);
5211 }
5212 40175665 }
5213
5214
5215
5216 void bmp_do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5217 {
5218 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5219 {
5220 Z_scripterrlog("bitmap->DrawCharacter() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5221 return;
5222 }
5223 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5224 if ( refbmp == NULL ) return;
5225
5226 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5227
5228 //broken 2.50.2 and earlier drawcharacter()
5229 if ( get_qr(qr_BROKENCHARINTDRAWING) )
5230 {
5231 //sdci[1]=layer
5232 //sdci[2]=x
5233 //sdci[3]=y
5234 //sdci[4]=font
5235 //sdci[5]=color
5236 //sdci[6]=bg color
5237 //sdci[7]=strech x (width)
5238 //sdci[8]=stretch y (height)
5239 //sdci[9]=char
5240 //sdci[10]=opacity
5241 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5242
5243 int32_t x=sdci[2]/10000;
5244 int32_t y=sdci[3]/10000;
5245 int32_t font_index=sdci[4]/10000;
5246 int32_t color=sdci[5]/10000;
5247 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5248 int32_t w=sdci[7]/10000;
5249 int32_t h=sdci[8]/10000;
5250 char glyph=char(sdci[9]/10000);
5251 int32_t opacity=sdci[10]/10000;
5252
5253 //safe check
5254 if(bg_color < -1) bg_color = -1;
5255
5256 if(w>512) w=512; //w=vbound(w,0,512);
5257
5258 if(h>512) h=512; //h=vbound(h,0,512);
5259
5260 //undone
5261 if(w>0&&h>0)//stretch the character
5262 {
5263 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5264
5265 if(opacity < 128)
5266 {
5267 if(w>128||h>128)
5268 {
5269 clear_bitmap(prim_bmp);
5270
5271 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5272 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5273 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5274 }
5275 else //this is faster
5276 {
5277 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5278
5279 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5280 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5281 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5282
5283 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5284 }
5285 }
5286 else // no opacity
5287 {
5288 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5289 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5290 }
5291
5292 }
5293 else //no stretch
5294 {
5295 if(opacity < 128)
5296 {
5297 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5298 clear_bitmap(pbmp);
5299
5300 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5301 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5302
5303 destroy_bitmap(pbmp);
5304 }
5305 else // no opacity
5306 {
5307 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5308 }
5309 }
5310 }
5311
5312 else //2.53.0 fixed version and later.
5313 {
5314
5315 //sdci[1]=layer
5316 //sdci[2]=x
5317 //sdci[3]=y
5318 //sdci[4]=font
5319 //sdci[5]=color
5320 //sdci[6]=bg color
5321 //sdci[7]=strech x (width)
5322 //sdci[8]=stretch y (height)
5323 //sdci[9]=char
5324 //sdci[10]=opacity
5325
5326 int32_t x=sdci[2]/10000;
5327 int32_t y=sdci[3]/10000;
5328 int32_t font_index=sdci[4]/10000;
5329 int32_t color=sdci[5]/10000;
5330 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5331 int32_t w=sdci[7]/10000;
5332 int32_t h=sdci[8]/10000;
5333 char glyph=char(sdci[9]/10000);
5334 int32_t opacity=sdci[10]/10000;
5335
5336 //safe check
5337 if(bg_color < -1) bg_color = -1;
5338
5339 if(w>512) w=512; //w=vbound(w,0,512);
5340
5341 if(h>512) h=512; //h=vbound(h,0,512);
5342
5343 //undone
5344 if(w>0&&h>0)//stretch the character
5345 {
5346 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5347
5348 if(opacity < 128)
5349 {
5350 if(w>128||h>128)
5351 {
5352 clear_bitmap(prim_bmp);
5353
5354 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5355 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5356 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5357 }
5358 else //this is faster
5359 {
5360 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5361
5362 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5363 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5364 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5365
5366 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5367 }
5368 }
5369 else // no opacity
5370 {
5371 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5372 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5373 }
5374
5375 }
5376 else //no stretch
5377 {
5378 if(opacity < 128)
5379 {
5380 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5381 clear_bitmap(pbmp);
5382
5383 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5384 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5385
5386 destroy_bitmap(pbmp);
5387 }
5388 else // no opacity
5389 {
5390 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5391 }
5392 }
5393
5394 }
5395
5396 }
5397
5398
5399 void bmp_do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5400 {
5401 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5402 {
5403 Z_scripterrlog("bitmap->DrawInteger() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5404 return;
5405 }
5406 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5407 if ( refbmp == NULL ) return;
5408
5409 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5410
5411 //broken 2.50.2 and earlier drawinteger()
5412 if ( get_qr(qr_BROKENCHARINTDRAWING) )
5413 {
5414 //sdci[1]=layer
5415 //sdci[2]=x
5416 //sdci[3]=y
5417 //sdci[4]=font
5418 //sdci[5]=color
5419 //sdci[6]=bg color
5420 //sdci[7]=strech x (width)
5421 //sdci[8]=stretch y (height)
5422 //sdci[9]=integer
5423 //sdci[10]=num decimal places
5424 //sdci[11]=opacity
5425 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5426
5427 int32_t x=sdci[2]/10000;
5428 int32_t y=sdci[3]/10000;
5429 int32_t font_index=sdci[4]/10000;
5430 int32_t color=sdci[5]/10000;
5431 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5432 int32_t w=sdci[7]/10000;
5433 int32_t h=sdci[8]/10000;
5434 int32_t decplace=sdci[10]/10000;
5435 int32_t opacity=sdci[11]/10000;
5436
5437 //safe check
5438 if(bg_color < -1) bg_color = -1;
5439
5440 if(w>512) w=512; //w=vbound(w,0,512);
5441
5442 if(h>512) h=512; //h=vbound(h,0,512);
5443
5444 char numbuf[15];
5445
5446 switch(decplace)
5447 {
5448 default:
5449 case 0:
5450 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5451 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5452
5453 case 1:
5454 //sprintf(numbuf,"%.01f",number);
5455 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5456 break;
5457
5458 case 2:
5459 //sprintf(numbuf,"%.02f",number);
5460 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5461 break;
5462
5463 case 3:
5464 //sprintf(numbuf,"%.03f",number);
5465 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5466 break;
5467
5468 case 4:
5469 //sprintf(numbuf,"%.04f",number);
5470 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5471 break;
5472 }
5473
5474 if(w>0&&h>0)//stretch
5475 {
5476 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5477
5478 if(opacity < 128)
5479 {
5480 if(w>128||h>128)
5481 {
5482 clear_bitmap(prim_bmp);
5483
5484 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5485 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5486 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5487 }
5488 else
5489 {
5490 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5491 clear_bitmap(pbmp2);
5492
5493 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5494 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5495 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5496
5497 destroy_bitmap(pbmp2);
5498 }
5499 }
5500 else // no opacity
5501 {
5502 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5503 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5504 }
5505
5506 }
5507 else //no stretch
5508 {
5509 if(opacity < 128)
5510 {
5511 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5512 clear_bitmap(pbmp);
5513
5514 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5515 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5516
5517 destroy_bitmap(pbmp);
5518 }
5519 else // no opacity
5520 {
5521 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5522 }
5523 }
5524
5525 }
5526
5527 else //2.53.0 fixed version and later.
5528 {
5529 //sdci[1]=layer
5530 //sdci[2]=x
5531 //sdci[3]=y
5532 //sdci[4]=font
5533 //sdci[5]=color
5534 //sdci[6]=bg color
5535 //sdci[7]=strech x (width)
5536 //sdci[8]=stretch y (height)
5537 //sdci[9]=integer
5538 //sdci[10]=num decimal places
5539 //sdci[11]=opacity
5540
5541 int32_t x=sdci[2]/10000;
5542 int32_t y=sdci[3]/10000;
5543 int32_t font_index=sdci[4]/10000;
5544 int32_t color=sdci[5]/10000;
5545 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5546 int32_t w=sdci[7]/10000;
5547 int32_t h=sdci[8]/10000;
5548 int32_t decplace=sdci[10]/10000;
5549 int32_t opacity=sdci[11]/10000;
5550
5551 //safe check
5552 if(bg_color < -1) bg_color = -1;
5553
5554 if(w>512) w=512; //w=vbound(w,0,512);
5555
5556 if(h>512) h=512; //h=vbound(h,0,512);
5557
5558 char numbuf[15];
5559
5560 switch(decplace)
5561 {
5562 default:
5563 case 0:
5564 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5565 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5566
5567 case 1:
5568 //sprintf(numbuf,"%.01f",number);
5569 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5570 break;
5571
5572 case 2:
5573 //sprintf(numbuf,"%.02f",number);
5574 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5575 break;
5576
5577 case 3:
5578 //sprintf(numbuf,"%.03f",number);
5579 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5580 break;
5581
5582 case 4:
5583 //sprintf(numbuf,"%.04f",number);
5584 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5585 break;
5586 }
5587
5588 //FONT* font=get_zc_font(sdci[4]/10000);
5589
5590 if(w>0&&h>0)//stretch
5591 {
5592 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
5593 clear_bitmap(pbmp);
5594 //script_drawing_commands.GetSmallTextureBitmap(1,1);
5595
5596 if(opacity < 128)
5597 {
5598 if(w>128||h>128)
5599 {
5600 clear_bitmap(prim_bmp);
5601
5602 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5603 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5604 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5605 }
5606 else
5607 {
5608 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5609 clear_bitmap(pbmp2);
5610
5611 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5612 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5613 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5614
5615 destroy_bitmap(pbmp2);
5616 }
5617 }
5618 else // no opacity
5619 {
5620 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5621 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5622 }
5623
5624 }
5625 else //no stretch
5626 {
5627 if(opacity < 128)
5628 {
5629 FONT* font = get_zc_font(font_index);
5630 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
5631 clear_bitmap(pbmp);
5632
5633 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
5634 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5635
5636 destroy_bitmap(pbmp);
5637 }
5638 else // no opacity
5639 {
5640 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5641 }
5642 }
5643 }
5644 }
5645
5646
5647 865 void bmp_do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5648 {
5649 //sdci[1]=layer
5650 //sdci[2]=x
5651 //sdci[3]=y
5652 //sdci[4]=font
5653 //sdci[5]=color
5654 //sdci[6]=bg color
5655 //sdci[7]=format_option
5656 //sdci[8]=string
5657 //sdci[9]=opacity
5658 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5660 {
5661 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5662 return;
5663 }
5664
5665 865 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5666
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if ( refbmp == NULL ) return;
5667
5668
2/4
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 865 times.
865 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5669
5670 865 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5671
5672
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if(!str)
5673 {
5674 al_trace("String pointer is null! Internal error. \n");
5675 return;
5676 }
5677
5678 865 int32_t x=sdci[2]/10000;
5679 865 int32_t y=sdci[3]/10000;
5680 865 FONT* font=get_zc_font(sdci[4]/10000);
5681 865 int32_t color=sdci[5]/10000;
5682 865 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5683 865 int32_t format_type=sdci[7]/10000;
5684 865 int32_t opacity=sdci[9]/10000;
5685 //sdci[8] not needed :)
5686
5687 //safe check
5688
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if(bg_color < -1) bg_color = -1;
5689
5690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if(opacity < 128)
5691 {
5692 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5693 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5694 clear_bitmap(pbmp);
5695 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
5696 if(format_type == 2) // right-sided text
5697 x-=width;
5698 else if(format_type == 1) // centered text
5699 x-=width/2;
5700 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5701 destroy_bitmap(pbmp);
5702 }
5703 else // no opacity
5704 {
5705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if(format_type == 2) // right-sided text
5706 {
5707 textout_right_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5708 }
5709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if(format_type == 1) // centered text
5710 {
5711 textout_centre_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5712 }
5713 else // standard left-sided text
5714 {
5715 865 textout_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5716 }
5717 }
5718 865 }
5719
5720 45504 void bmp_do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5721 {
5722 //sdci[1]=layer
5723 //sdci[2]=x
5724 //sdci[3]=y
5725 //sdci[4]=font
5726 //sdci[5]=color
5727 //sdci[6]=bg color
5728 //sdci[7]=format_option
5729 //sdci[8]=string
5730 //sdci[9]=opacity
5731 //sdci[10]=shadowtype
5732 //sdci[11]=shadow_color
5733 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5735 {
5736 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5737 return;
5738 }
5739
5740 45504 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5741
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if ( refbmp == NULL ) return;
5742
5743
2/4
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45504 times.
45504 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5744
5745 45504 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5746
5747
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(!str)
5748 {
5749 al_trace("String pointer is null! Internal error. \n");
5750 return;
5751 }
5752
5753 45504 int32_t x=sdci[2]/10000;
5754 45504 int32_t y=sdci[3]/10000;
5755 45504 FONT* font=get_zc_font(sdci[4]/10000);
5756 45504 int32_t color=sdci[5]/10000;
5757 45504 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5758 45504 int32_t format_type=sdci[7]/10000;
5759 45504 int32_t opacity=sdci[9]/10000;
5760 45504 int32_t textstyle = sdci[10]/10000;
5761 45504 int32_t shadow_color = sdci[11]/10000;
5762 //sdci[8] not needed :)
5763
5764 //safe check
5765
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(bg_color < -1) bg_color = -1;
5766
5767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if(opacity < 128)
5768 {
5769 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5770 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5771 clear_bitmap(pbmp);
5772 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, sstaLEFT, color, shadow_color, bg_color);
5773 if(format_type == 2) // right-sided text
5774 x-=width;
5775 else if(format_type == 1) // centered text
5776 x-=width/2;
5777 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5778 destroy_bitmap(pbmp);
5779 }
5780 else // no opacity
5781 {
5782 45504 textout_styled_aligned_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
5783 }
5784 45504 }
5785
5786 2134433 void bmp_do_clearr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5787 {
5788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2134433 times.
2134433 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5789 {
5790 Z_scripterrlog("bitmap->Clear() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5791 return;
5792 }
5793
5794 2134433 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2134433 times.
2134433 if ( !refbmp ) return;
5796
5797 2134433 clear_bitmap(refbmp);
5798 2134433 }
5799
5800 34749 void bmp_do_clearcolorr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5801 {
5802 //sdci[1]=layer
5803 //sdci[2]=color
5804 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5805 34749 int32_t pal_color = sdci[2]/10000;
5806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34749 times.
34749 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5807 {
5808 Z_scripterrlog("bitmap->ClearToColor() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5809 return;
5810 }
5811
5812 34749 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34749 times.
34749 if ( !refbmp ) return;
5814
5815 34749 clear_to_color(refbmp, pal_color);
5816 34749 }
5817
5818
5819 43007 void bmp_do_regenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5820 {
5821 //sdci[1]=layer
5822 43007 int32_t h = sdci[3]/10000;
5823 43007 int32_t w = sdci[2]/10000;
5824
1/2
✓ Branch 0 taken 43007 times.
✗ Branch 1 not taken.
43007 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
5825 {
5826 //flip height and width
5827 h = h ^ w;
5828 w = h ^ w;
5829 h = h ^ w;
5830 }
5831 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5832 //Z_scripterrlog("bitmap->Create() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43007 times.
43007 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5834 {
5835 Z_scripterrlog("bitmap->Create() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5836 return;
5837 }
5838 43007 int32_t bitid = sdci[DRAWCMD_BMP_TARGET];
5839 43007 auto& usr_bmp = scb.get(bitid);
5840
2/2
✓ Branch 0 taken 42757 times.
✓ Branch 1 taken 250 times.
43007 if ( usr_bmp.u_bmp )
5841 42757 destroy_bitmap(usr_bmp.u_bmp);
5842 43007 usr_bmp.u_bmp = create_bitmap_ex(8,w,h);
5843
5844 43007 usr_bmp.width = w;
5845 43007 usr_bmp.height = h;
5846 43007 }
5847
5848 void bmp_do_readr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5849 {
5850 //sdci[1]=layer
5851 //sdci[2]=filename
5852 //sdci[3]=y
5853 //sdci[4]=font
5854 //sdci[5]=color
5855 //sdci[6]=bg color
5856 //sdci[7]=format_option
5857 //sdci[8]=string
5858 //sdci[9]=opacity
5859 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5860 //Z_scripterrlog("bitmap->Read() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5861 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5862 {
5863 Z_scripterrlog("bitmap->Read() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5864 return;
5865 }
5866 int32_t bitid = sdci[DRAWCMD_BMP_TARGET];
5867 auto& usr_bitmap = scb.get(bitid);
5868 usr_bitmap.destroy();
5869
5870 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5871
5872 if(!str)
5873 {
5874 al_trace("String pointer is null! Internal error. \n");
5875 return;
5876 }
5877
5878 PALETTE tempPal;
5879 get_palette(tempPal);
5880 if ( checkPath(str->c_str(), false) )
5881 {
5882 usr_bitmap.u_bmp = load_bitmap(str->c_str(), tempPal);
5883 usr_bitmap.width = usr_bitmap.u_bmp->w;
5884 usr_bitmap.height = usr_bitmap.u_bmp->h;
5885 if ( !usr_bitmap.u_bmp )
5886 {
5887 Z_scripterrlog("Failed to load image file %s.\nMaking a blank bitmap on the pointer.\n", str->c_str());
5888 }
5889 else
5890 {
5891 zprint("Read image file %s\n",str->c_str());
5892 }
5893 }
5894 else
5895 {
5896 Z_scripterrlog("Failed to load image file: %s. File not found. Creating a blank bitmap on the pointer.\n", str->c_str());
5897 usr_bitmap.u_bmp = create_bitmap_ex(8,256,176);
5898 clear_bitmap(usr_bitmap.u_bmp);
5899 }
5900 }
5901
5902
5903
5904 void bmp_do_writer(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5905 {
5906 //sdci[1]=layer
5907 //sdci[2]=filename
5908 //sdci[3]=y
5909 //sdci[4]=font
5910 //sdci[5]=color
5911 //sdci[6]=bg color
5912 //sdci[7]=format_option
5913 //sdci[8]=string
5914 //sdci[9]=opacity
5915 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5916 //Z_scripterrlog("bitmap->Write() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5917
5918 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5919 {
5920 Z_scripterrlog("bitmap->Write() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5921 return;
5922 }
5923
5924 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5925 if ( !refbmp ) return;
5926
5927 bool overwrite = (sdci[3] != 0);
5928 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5929
5930 if(!str)
5931 {
5932 al_trace("String pointer is null! Internal error. \n");
5933 return;
5934 }
5935
5936 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
5937 //std::strncpy(cptr, str->c_str(), str->size());
5938 //Z_scripterrlog("bitmap->Write extension matches ? : %s\n!", (FFCore.checkExtension(str->c_str(), ".png")) ? "true" : "false");
5939 //Z_scripterrlog("Trying to write filename %s\n", cptr);
5940 if
5941 (
5942 ( (FFCore.checkExtension(*str, "")) ) ||
5943 ( !(FFCore.checkExtension(*str, ".png")) && !(FFCore.checkExtension(*str, ".gif")) && !(FFCore.checkExtension(*str, ".bmp"))
5944 && !(FFCore.checkExtension(*str, ".pcx")) && !(FFCore.checkExtension(*str, ".tga")) )
5945 )
5946 {
5947 Z_scripterrlog("No extension, or invalid extension provided for writing bitmap file %s. Could not write the file.\nValid types are .png, .gif, .pcx, .tgx, and .bmp. Aborting.\n",str->c_str());
5948 }
5949 else if ( overwrite || (!checkPath(str->c_str(), false)) )
5950 {
5951 if(make_dirs_for_file(*str))
5952 {
5953 save_bitmap(str->c_str(), refbmp, RAMpal);
5954 if(checkPath(str->c_str(), false))
5955 {
5956 zprint("Wrote image file %s\n",str->c_str());
5957 }
5958 else
5959 {
5960 Z_scripterrlog("Failed to create file '%s'\n",str->c_str());
5961 }
5962 }
5963 else
5964 {
5965 Z_scripterrlog("Cannot write file '%s' because the directory does not exist, and could not be created.\n", str->c_str());
5966 }
5967 }
5968 else Z_scripterrlog("Cannot write file '%s' because the file already exists in the specified path.\n", str->c_str());
5969 }
5970
5971
5972 void bmp_do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5973 {
5974 //sdci[1]=layer
5975 //sdci[2]=x1
5976 //sdci[3]=y1
5977 //sdci[4]=x2
5978 //sdci[5]=y2
5979 //sdci[6]=x3
5980 //sdci[7]=y3
5981 //sdci[8]=x4
5982 //sdci[9]=y4
5983 //sdci[10]=width
5984 //sdci[11]=height
5985 //sdci[12]=cset
5986 //sdci[13]=flip
5987 //sdci[14]=tile/combo
5988 //sdci[15]=polytype
5989 //sdci[16] = other bitmap as texture
5990 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5991 Z_scripterrlog("bitmap quad pointer: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5992 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5993 {
5994 Z_scripterrlog("bitmap->Quad() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5995 return;
5996 }
5997 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5998
5999 if ( !refbmp ) return;
6000
6001 int32_t x1 = sdci[2]/10000;
6002 int32_t y1 = sdci[3]/10000;
6003 int32_t x2 = sdci[4]/10000;
6004 int32_t y2 = sdci[5]/10000;
6005 int32_t x3 = sdci[6]/10000;
6006 int32_t y3 = sdci[7]/10000;
6007 int32_t x4 = sdci[8]/10000;
6008 int32_t y4 = sdci[9]/10000;
6009 int32_t w = sdci[10]/10000;
6010 int32_t h = sdci[11]/10000;
6011 int32_t color = sdci[12]/10000;
6012 int32_t flip=(sdci[13]/10000)&3;
6013 int32_t tile = sdci[14]/10000;
6014 int32_t polytype = sdci[15]/10000;
6015 int32_t quad_render_source = sdci[16];
6016 //Z_scripterrlog("bitmap->Quad() render source is: %d\n", quad_render_source);
6017
6018 bool tex_is_bitmap = ( sdci[16] != 0 );
6019
6020 BITMAP *bmptexture=NULL;
6021 BITMAP *tex=NULL;
6022 polytype = vbound(polytype, 0, 14);
6023
6024 int32_t col[4];
6025 col[0]=col[1]=col[2]=col[3]=color;
6026 bool mustDestroyBmp = false;
6027
6028 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6029
6030 if ( tex_is_bitmap )
6031 {
6032 bmptexture = resolveScriptingBitmap(quad_render_source);
6033 if ( !bmptexture )
6034 {
6035 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
6036 tex_is_bitmap = 0;
6037 }
6038 }
6039
6040 if ( tex_is_bitmap )
6041 {
6042
6043 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6044 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6045 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", w);
6046 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", h);
6047
6048 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6049 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6050 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6051 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6052
6053 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
6054 }
6055 else
6056 {
6057 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6058 if(!tex)
6059 {
6060 //Z_scripterrlog("Bitmap->Quad() found an invalid texture bitmap.\n");
6061 mustDestroyBmp = true;
6062 tex = create_bitmap_ex(8, w*16, h*16);
6063 clear_bitmap(tex);
6064 }
6065
6066 if(tile > 0) // TILE
6067 {
6068 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6069 }
6070
6071 if ( tile < 0 ) // COMBO
6072 {
6073 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
6074 const int32_t tiletodraw = combo_tile(c, x1, y1);
6075 flip = flip ^ c.flip;
6076
6077 if(!(c.animflags & AF_EDITOR_ONLY))
6078 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6079 }
6080 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6081 {
6082 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6083 return; //non power of two error
6084 }
6085 //Z_scripterrlog("bitmap->Quad() is trying to blit from a bitmap texture.\n");
6086 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6087 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6088 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6089 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6090
6091 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
6092
6093 }
6094
6095
6096
6097
6098 //todo: finish palette shading
6099 /*
6100 POLYTYPE_FLAT
6101 POLYTYPE_GCOL
6102 POLYTYPE_GRGB
6103 POLYTYPE_ATEX
6104 POLYTYPE_PTEX
6105 POLYTYPE_ATEX_MASK
6106 POLYTYPE_PTEX_MASK
6107 POLYTYPE_ATEX_LIT
6108 POLYTYPE_PTEX_LIT
6109 POLYTYPE_ATEX_MASK_LIT
6110 POLYTYPE_PTEX_MASK_LIT
6111 POLYTYPE_ATEX_TRANS
6112 POLYTYPE_PTEX_TRANS
6113 POLYTYPE_ATEX_MASK_TRANS
6114 POLYTYPE_PTEX_MASK_TRANS
6115 */
6116
6117 if(mustDestroyBmp)
6118 destroy_bitmap(tex);
6119
6120 }
6121
6122 void bmp_do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6123 {
6124 //sdci[1]=layer
6125 //sdci[2]=x1
6126 //sdci[3]=y1
6127 //sdci[4]=x2
6128 //sdci[5]=y2
6129 //sdci[6]=x3
6130 //sdci[7]=y3
6131 //sdci[8]=width
6132 //sdci[9]=height
6133 //sdci[10]=cset
6134 //sdci[11]=flip
6135 //sdci[12]=tile/combo
6136 //sdci[13]=polytype
6137 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6138 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
6139 {
6140 Z_scripterrlog("bitmap->Triangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
6141 return;
6142 }
6143 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
6144 if ( refbmp == NULL ) return;
6145
6146
6147 int32_t render_source = sdci[14];
6148 //Z_scripterrlog("bitmap->Triangle() render source is: %d\n", render_source);
6149
6150 bool tex_is_bitmap = ( sdci[14] != 0 );
6151
6152 BITMAP *bmptexture=NULL;
6153 if ( tex_is_bitmap )
6154 {
6155 bmptexture = resolveScriptingBitmap(render_source);
6156 if ( !bmptexture )
6157 {
6158 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
6159 tex_is_bitmap = 0;
6160 }
6161 }
6162
6163 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6164
6165 int32_t x1 = sdci[2]/10000;
6166 int32_t y1 = sdci[3]/10000;
6167 int32_t x2 = sdci[4]/10000;
6168 int32_t y2 = sdci[5]/10000;
6169 int32_t x3 = sdci[6]/10000;
6170 int32_t y3 = sdci[7]/10000;
6171 int32_t w = sdci[8]/10000;
6172 int32_t h = sdci[9]/10000;
6173 int32_t color = sdci[10]/10000;
6174 int32_t flip=(sdci[11]/10000)&3;
6175 int32_t tile = sdci[12]/10000;
6176 int32_t polytype = sdci[13]/10000;
6177
6178 polytype = vbound(polytype, 0, 14);
6179 int32_t utex_w = w;
6180 int32_t utex_h = h;
6181
6182
6183 int32_t tex_width = w*16;
6184 int32_t tex_height = h*16;
6185
6186 bool mustDestroyBmp = false;
6187 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6188
6189 if(!tex)
6190 {
6191 mustDestroyBmp = true;
6192 tex = create_bitmap_ex(8, tex_width, tex_height);
6193 clear_bitmap(tex);
6194 }
6195
6196 int32_t col[3];
6197 /*
6198 if( color < 0 )
6199 {
6200 col[0]=draw_container.color_buffer[0];
6201 col[1]=draw_container.color_buffer[1];
6202 col[2]=draw_container.color_buffer[2];
6203 }
6204 else */
6205 {
6206 col[0]=col[1]=col[2]=color;
6207 }
6208
6209 if(tile > 0) // TILE
6210 {
6211 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6212 }
6213 else // COMBO
6214 {
6215 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
6216 const int32_t tiletodraw = combo_tile(c, x1, y1);
6217 flip = flip ^ c.flip;
6218
6219 if(!(c.animflags & AF_EDITOR_ONLY))
6220 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6221 }
6222 if ( !tex_is_bitmap )
6223 {
6224 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6225 {
6226 Z_message("bitmap->Triangle() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6227 return; //non power of two error
6228 }
6229 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6230 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
6231 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
6232
6233
6234 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
6235
6236 }
6237
6238 else
6239 {
6240 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6241 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6242 if ( !isPowerOfTwo(utex_h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_w);
6243 if ( !isPowerOfTwo(utex_w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_h);
6244
6245 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6246 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(utex_h), col[1] };
6247 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(utex_w), static_cast<float>(utex_h), col[2] };
6248
6249
6250 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
6251
6252 }
6253
6254 if(mustDestroyBmp)
6255 destroy_bitmap(tex);
6256 }
6257
6258
6259 void bmp_do_mode7r(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6260 {
6261 /*
6262 int32_t layer, int32_t rt, int32_t srcX, int32_t srcY, int32_t srcW, int32_t srcH, int32_t destW, int32_t destH, int32_t angle, int32_t cx, int32_t cy, int32_t space_z, int32_t horizon,
6263 int32_t scale_x, int32_t scale_y){
6264
6265 //sdci[1]=layer
6266 //sdci[2]=bitmap target
6267 //
6268 // -2 is the current Render Target
6269 // -1, this is the screen (framebuf).
6270 // 0: Render target 0
6271 // 1: Render target 1
6272 // 2: Render target 2
6273 // 3: Render target 3
6274 // 4: Render target 4
6275 // 5: Render target 5
6276 // 6: Render target 6
6277 // Otherwise: The pointer to a bitmap.
6278
6279 //sdci[3]=sourcex
6280 //sdci[4]=sourcey
6281 //sdci[5]=sourcew
6282 //sdci[6]=sourceh
6283
6284 //sdci[7]=destw
6285 //sdci[8]=desth
6286 //sdci[9]=angle
6287 //scdi[10] = pivot cx
6288 //sdci[11] = pivot cy
6289 //sdci[12] = space Z
6290 //sdci[13] = horizon
6291 //scdi[14] = scale X
6292 //scdi[15] = scale Y
6293 //sdci[16] = masked?
6294 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6295
6296
6297
6298 // ZScript-side constant values:
6299 const int32_t BITDX_NORMAL = 0;
6300 const int32_t BITDX_TRANS = 1; //Translucent
6301 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6302 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6303 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6304 //Note: Some modes cannot be combined. if a combination is not supported, an error
6305 // detailing this will be shown in allegro.log.
6306
6307 //scdi[15] = litcolour
6308 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6309 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6310
6311 //sdci[16]=mask
6312
6313 */
6314
6315
6316 int32_t bitmapIndex = sdci[2];
6317 int32_t usr_bitmap_index = sdci[2];
6318 //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex);
6319 //Z_scripterrlog("DrawPlane() bitmapIndex is: %d\n", bitmapIndex);
6320
6321 if ( bitmapIndex >= 10000 )
6322 {
6323 bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8;
6324 }
6325 else if ( usr_bitmap_index > 0 )
6326 {
6327 bitmapIndex = usr_bitmap_index;
6328 // Z_scripterrlog("Mode7 is using a user bitmap target, pointer: %d\n", usr_bitmap_index);
6329 yoffset = 0;
6330 }
6331
6332 //rendering mode 7 args
6333 double srcX = sdci[3]/10000.0;
6334 double srcY = sdci[4]/10000.0;
6335 double destX = sdci[5]/10000.0;
6336 double destY = sdci[6]/10000.0;
6337
6338 double destW = sdci[7]/10000.0;
6339 double destH = sdci[8]/10000.0;
6340 double space_z = sdci[9]/10000.0;
6341 double horizon = sdci[10]/10000.0;
6342 double scale_x = sdci[11]/10000.0;
6343 double scale_y = sdci[12]/10000.0;
6344 byte masked = ( sdci[13] ) ? 1 : 0;
6345
6346
6347 int32_t ref = 0;
6348
6349 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6350 //Do we need to also check the render target and do the same thing if the
6351 //dest == -2 and the render target is not RT_SCREEN?
6352
6353 ref = sdci[DRAWCMD_BMP_TARGET];
6354
6355
6356 if ( ref <= 0 )
6357 {
6358 Z_scripterrlog("bitmap->DrawPlane() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6359 return;
6360 }
6361 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
6362
6363 if(!sourceBitmap)
6364 {
6365 Z_message("Warning: %d->DrawPlane() source bitmap contains invalid data or is not initialized.\n", ref);
6366 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6367 return;
6368 }
6369
6370 BITMAP *destBMP=NULL;
6371 switch(bitmapIndex)
6372 {
6373 // Current render target (RT_CURRENT).
6374 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
6375 case -2:
6376 {
6377 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6378 if ( curr_rt >= 0 && curr_rt < 7 )
6379 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6380 else destBMP = bmp; //screen
6381 break;
6382 }
6383 case -1:
6384 destBMP = bmp; //this is framebuf, by default
6385 break;
6386
6387 //1 through 6 are the old system bitmaps (Render Targets)
6388 case 0:
6389 case 1:
6390 case 2:
6391 case 3:
6392 case 4:
6393 case 5:
6394 case 6:
6395 {
6396 //This gets a render target.
6397 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6398 break;
6399 }
6400 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6401 default:
6402 {
6403 auto& usr_bitmap = scb.get(usr_bitmap_index);
6404 destBMP = usr_bitmap.u_bmp;
6405 if ( !usr_bitmap.u_bmp )
6406 {
6407 Z_scripterrlog("Target for bitmap->DrawPlane is uninitialised. Aborting.\n");
6408 break;
6409 }
6410 }
6411 }
6412
6413 if (!destBMP)
6414 {
6415 Z_message("Warning: DrawPlane(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6416 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6417 return;
6418 }
6419
6420 //dx = dx + xoffset; //don't do this here!
6421 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6422 //All of these are a factor of 10000 as fix.
6423 int32_t screen_x = 0; int32_t screen_y = 0;
6424
6425 double distance = 0; double horizontal_scale = 0;
6426
6427 int32_t screen_y_horizon = 0;
6428
6429 double line_dx = 0; double line_dy = 0;
6430
6431 int32_t space_x = 0; int32_t space_y = 0;
6432
6433 for(screen_y = 0; screen_y < destH; screen_y++) //fix, offset by .0000
6434 {
6435 //Calculate the distance of each line from the camera point
6436 screen_y_horizon = screen_y + horizon;
6437
6438 distance = ((space_z * scale_y) / ((screen_y_horizon != 0) ? screen_y_horizon : 1));
6439
6440 //Get the scale of each line based on the distance
6441
6442 horizontal_scale = (distance / (( scale_x != 0 ) ? scale_x : 1));
6443
6444 //There was some math here before I stripped out the rotation step
6445 line_dx = horizontal_scale;
6446 line_dy = 0;
6447
6448 //space_x,space_y - where to grab each scanline from on the space bitmap
6449 space_x = srcX - destW/2.0 * line_dx;
6450 space_y = srcY - distance + destH/2.0 * line_dy;
6451
6452 //Keep blits within the bounds of both bitmaps to avoid crashes
6453 int32_t y1 = srcY+space_y;
6454 int32_t y2 = destY+screen_y;
6455 if(y1 >=0 && y1 <= (sourceBitmap->h-1) && y2 >=0 && y2 <= (destBMP->h-1) )
6456 {
6457 if ( masked ) masked_stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6458 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6459 else stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6460 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6461 }
6462 }
6463 }
6464
6465
6466 //Draw]()
6467 2062708 void bmp_do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6468 {
6469 /*
6470 //sdci[1]=layer
6471 //sdci[2]=bitmap target
6472 //
6473 // -2 is the current Render Target
6474 // -1, this is the screen (framebuf).
6475 // 0: Render target 0
6476 // 1: Render target 1
6477 // 2: Render target 2
6478 // 3: Render target 3
6479 // 4: Render target 4
6480 // 5: Render target 5
6481 // 6: Render target 6
6482 // Otherwise: The pointer to a bitmap.
6483
6484 //sdci[3]=sourcex
6485 //sdci[4]=sourcey
6486 //sdci[5]=sourcew
6487 //sdci[6]=sourceh
6488 //sdci[7]=destx
6489 //sdci[8]=desty
6490 //sdci[9]=destw
6491 //sdci[10]=desth
6492 //sdci[11]=rotation/angle
6493 //scdi[12] = pivot cx
6494 //sdci[13] = pivot cy
6495 //scdi[14] = effect flags
6496 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6497
6498 // ZScript-side constant values:
6499 const int32_t BITDX_NORMAL = 0;
6500 const int32_t BITDX_TRANS = 1; //Translucent
6501 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6502 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6503 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6504 //Note: Some modes cannot be combined. if a combination is not supported, an error
6505 // detailing this will be shown in allegro.log.
6506
6507 //scdi[15] = litcolour
6508 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6509 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6510
6511 //sdci[16]=mask
6512
6513 */
6514
6515 2062708 int32_t usr_bitmap_index = sdci[2];
6516 4125416 auto [bitmapIndex, is_user_bitmap] = resolveScriptingBitmapId(usr_bitmap_index);
6517
6518
6519 2062708 int32_t sx = sdci[3]/10000;
6520 2062708 int32_t sy = sdci[4]/10000;
6521 2062708 int32_t sw = sdci[5]/10000;
6522 2062708 int32_t sh = sdci[6]/10000;
6523 2062708 int32_t dx = sdci[7]/10000;
6524 2062708 int32_t dy = sdci[8]/10000;
6525 2062708 int32_t dw = sdci[9]/10000;
6526 2062708 int32_t dh = sdci[10]/10000;
6527 2062708 float rot = sdci[11]/10000;
6528 2062708 int32_t cx = sdci[12]/10000;
6529 2062708 int32_t cy = sdci[13]/10000;
6530 2062708 int32_t mode = sdci[14]/10000;
6531 2062708 int32_t litcolour = sdci[15]/10000;
6532 2062708 bool masked = (sdci[16] != 0);
6533
6534 2062708 int32_t ref = 0;
6535
6536
2/2
✓ Branch 0 taken 267486 times.
✓ Branch 1 taken 1795222 times.
2062708 if (get_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN))
6537 {
6538
2/2
✓ Branch 0 taken 95143 times.
✓ Branch 1 taken 172343 times.
267486 if (is_user_bitmap)
6539 172343 yoffset = 0;
6540
6541 267486 dx += xoffset;
6542 267486 dy += yoffset;
6543 267486 }
6544 else
6545 {
6546 1795222 dx += secondary_draw_origin_xoff;
6547 1795222 dy += secondary_draw_origin_yoff;
6548
6549 1795222 sx += xoffset;
6550 1795222 sy += yoffset;
6551 }
6552
6553 2062708 ref = sdci[DRAWCMD_BMP_TARGET];
6554
6555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2062708 times.
2062708 if ( ref <= 0 )
6556 {
6557 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6558 return;
6559 }
6560 2062708 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
6561
6562
1/2
✓ Branch 0 taken 2062708 times.
✗ Branch 1 not taken.
2062708 if(!sourceBitmap)
6563 {
6564
6565 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
6566 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6567 return;
6568 }
6569
6570 2062708 BITMAP *destBMP=NULL;
6571
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224018 times.
✓ Branch 2 taken 14218 times.
✓ Branch 3 taken 1824472 times.
2062708 switch(bitmapIndex)
6572 {
6573 // Current render target (RT_CURRENT).
6574 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
6575 case -2:
6576 {
6577 14218 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6578
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14218 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14218 if ( curr_rt >= 0 && curr_rt < 7 )
6579 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6580 14218 else destBMP = bmp; //screen
6581 14218 break;
6582 }
6583 case -1:
6584 1824472 destBMP = bmp; //this is framebuf, by default
6585 1824472 break;
6586 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
6587 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
6588 //destBMP = framebuf; //Drawing to the screen.
6589 //break;
6590
6591 //1 through 6 are the old system bitmaps (Render Targets)
6592 case 0:
6593 case 1:
6594 case 2:
6595 case 3:
6596 case 4:
6597 case 5:
6598 case 6:
6599 {
6600 //This gets a render target.
6601 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
6602
6603 //destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6604 //sdci[18] = bitmapIndex;
6605 break;
6606 }
6607 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6608 default:
6609 {
6610 224018 auto& usr_bitmap = scb.get(usr_bitmap_index);
6611 224018 destBMP = usr_bitmap.u_bmp;
6612 //sdci[18] = usr_bitmap_index;
6613
1/2
✓ Branch 0 taken 224018 times.
✗ Branch 1 not taken.
224018 if ( !usr_bitmap.u_bmp )
6614 {
6615 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
6616 break;
6617 }
6618 }
6619 224018 }
6620
6621
1/2
✓ Branch 0 taken 2062708 times.
✗ Branch 1 not taken.
2062708 if (!destBMP)
6622 {
6623 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6624 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6625 return;
6626 }
6627
6628
2/2
✓ Branch 0 taken 1511 times.
✓ Branch 1 taken 2061197 times.
2062708 bool stretched = (sw != dw || sh != dh);
6629 2062708 BITMAP* subBmp = 0;
6630
6631
4/4
✓ Branch 0 taken 2061129 times.
✓ Branch 1 taken 1579 times.
✓ Branch 2 taken 25732 times.
✓ Branch 3 taken 2035397 times.
2062708 if(rot != 0 || mode != 0)
6632 {
6633 27311 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
6634 27311 clear_bitmap(subBmp);
6635
6636
1/2
✓ Branch 0 taken 27311 times.
✗ Branch 1 not taken.
27311 if(!subBmp)
6637 {
6638
6639 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
6640 return;
6641 }
6642 27311 }
6643 2062708 BITMAP* sbmp = sourceBitmap;
6644
3/4
✓ Branch 0 taken 2061946 times.
✓ Branch 1 taken 762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2061946 times.
2062708 if (sx + sw > sbmp->w || sy + sh > sbmp->h)
6645 {
6646 762 sbmp = create_bitmap_ex(8, sw, sh);
6647 762 clear_bitmap(sbmp);
6648 762 blit(sourceBitmap, sbmp, sx, sy, 0, 0, std::min(sourceBitmap->w-sx, sw), std::min(sourceBitmap->h-sy, sh));
6649 762 sx = 0;
6650 762 sy = 0;
6651 762 }
6652 //dx = dx + xoffset; //don't do this here!
6653 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6654
6655
2/2
✓ Branch 0 taken 2086 times.
✓ Branch 1 taken 2060622 times.
2062708 if(stretched)
6656 {
6657
2/2
✓ Branch 0 taken 1475 times.
✓ Branch 1 taken 611 times.
2086 if(masked)
6658 { //stretched and masked
6659
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 901 times.
1475 if ( rot == 0 )
6660 { //if not rotated
6661
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
901 switch(mode)
6662 {
6663 case 1:
6664 //transparent
6665 900 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6666 900 draw_trans_sprite(destBMP, subBmp, dx, dy);
6667 900 break;
6668
6669
6670 case 2:
6671 //pivot?
6672 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6673 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6674 //Pivoting requires two more args
6675 break;
6676
6677 case 3:
6678 //pivot + trans
6679 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6680 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6681 break;
6682
6683 case 4:
6684 //flip v
6685 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6686 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
6687 break;
6688
6689 case 5:
6690 //trans + v flip
6691 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6692 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
6693 break;
6694
6695 case 6:
6696 //pivot + v flip
6697 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6698 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6699 break;
6700
6701 case 8:
6702 //vlip h
6703 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6704 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
6705 break;
6706
6707 case 9:
6708 //trans + h flip
6709 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6710 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
6711 break;
6712
6713 case 10:
6714 //flip H and pivot
6715 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6716 //return error cannot pivot and h flip
6717 break;
6718
6719 case 12:
6720 //vh flip
6721 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6722 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
6723 break;
6724
6725 case 13:
6726 //trans + vh flip
6727 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6728 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
6729 break;
6730
6731 case 14:
6732 //pivot and vh flip
6733 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
6734 //return error cannot both pivot and vh flip
6735 break;
6736
6737 case 16:
6738 //lit
6739 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6740 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
6741 break;
6742
6743 case 18:
6744 //pivot, lit
6745 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6746 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6747 break;
6748
6749 case 20:
6750 //lit + v flip
6751 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6752 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
6753 break;
6754
6755 case 22:
6756 //Pivot, vflip, lit
6757 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6758 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6759 break;
6760
6761 case 24:
6762 //lit + h flip
6763 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6764 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
6765 break;
6766
6767 case 26:
6768 //pivot + lit + hflip
6769 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
6770 //return error cannot pivot, lit, and flip
6771 break;
6772
6773 case 28:
6774 //lit + vh flip
6775 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6776 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
6777 break;
6778
6779 case 32: //gouraud
6780 //Probably not wort supporting.
6781 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6782 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
6783 break;
6784
6785 case 0:
6786 //no effect
6787 1 masked_stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
6788 1 break;
6789
6790
6791 default:
6792
6793 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
6794
6795
6796 }
6797 901 } //end if not rotated
6798
6799
2/2
✓ Branch 0 taken 901 times.
✓ Branch 1 taken 574 times.
1475 if ( rot != 0 ) //if rotated
6800 {
6801
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 574 times.
✗ Branch 21 not taken.
574 switch(mode)
6802 {
6803 case 1:
6804 //transparent
6805 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6806 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6807
6808 break;
6809
6810 case 2:
6811 //pivot?
6812 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6813 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6814 //Pivoting requires two more args
6815 break;
6816
6817 case 3:
6818 //pivot + trans
6819 //return an error, cannot both rotate and pivot
6820 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6821 break;
6822
6823 case 4:
6824 //flip v
6825 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6826 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6827 break;
6828
6829 case 5:
6830 //trans + v flip
6831 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6832 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6833 break;
6834
6835 case 6:
6836 //pivot + v flip
6837 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6838 //return an error, cannot both rotate and pivot
6839 break;
6840
6841 case 8:
6842 //flip h
6843 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
6844 //return an error, cannot both rotate and flip H
6845 break;
6846
6847 case 9:
6848 //trans + h flip
6849 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
6850 //return an error, cannot rotate and flip a trans sprite
6851 break;
6852
6853 case 10:
6854 //flip H and pivot
6855 //return error cannot pivot and h flip
6856 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6857 break;
6858
6859 case 12:
6860 //vh flip
6861 //return an error, cannot rotate and VH flip a trans sprite
6862 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6863 break;
6864
6865 case 13:
6866 //trans + vh flip
6867 //return an error, cannot rotate and VH flip a trans sprite
6868 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6869 break;
6870
6871 case 14:
6872 //pivot and vh flip
6873 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6874 //return error cannot both pivot and vh flip
6875 break;
6876
6877 case 16:
6878 //lit
6879 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6880 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6881 break;
6882
6883 case 18:
6884 //pivot, lit
6885 //return an error, cannot both rotate and pivot
6886 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6887 break;
6888
6889 case 20:
6890 //lit + vflip
6891 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6892 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6893 break;
6894
6895 case 22:
6896 //Pivot, vflip, lit
6897 //return an error, cannot both rotate and pivot
6898 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6899 break;
6900
6901 case 24:
6902 //lit + h flip
6903 //return an error, cannot both rotate and H flip
6904 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
6905 break;
6906
6907 case 26:
6908 //pivot + lit + hflip
6909 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
6910 //return error cannot pivot, lit, and flip
6911 break;
6912
6913 case 28:
6914 //lit + vh flip
6915 //return an error, cannot both rotate and VH flip
6916 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
6917 break;
6918
6919 case 32: //gouraud
6920 //Probably not wort supporting.
6921 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6922 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
6923 break;
6924
6925 case 0:
6926 //no effect.
6927 574 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6928 574 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6929 574 break;
6930
6931 default:
6932
6933 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
6934
6935 }
6936 574 }
6937 1475 } //end if stretched and masked
6938
6939 else //stretched, not masked
6940 {
6941
6942
6943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 611 times.
611 if ( rot == 0 ) //if not rotated
6944 {
6945
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 611 times.
611 switch(mode)
6946 {
6947 case 1:
6948 //transparent
6949 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6950 draw_trans_sprite(destBMP, subBmp, dx, dy);
6951 break;
6952
6953
6954 case 2:
6955 //pivot?
6956 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6957 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6958 //Pivoting requires two more args
6959 break;
6960
6961 case 3:
6962 //pivot + trans
6963 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6964 pivot_sprite_trans(destBMP, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
6965 break;
6966
6967 case 4:
6968 //flip v
6969 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6970 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
6971 break;
6972
6973 case 5:
6974 //trans + v flip
6975 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6976 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
6977 break;
6978
6979 case 6:
6980 //pivot + v flip
6981 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6982 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6983 break;
6984
6985 case 8:
6986 //vlip h
6987 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6988 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
6989 break;
6990
6991 case 9:
6992 //trans + h flip
6993 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6994 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
6995 break;
6996
6997 case 10:
6998 //flip H and pivot
6999 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7000 //return error cannot pivot and h flip
7001 break;
7002
7003 case 12:
7004 //vh flip
7005 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7006 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7007 break;
7008
7009 case 13:
7010 //trans + vh flip
7011 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7012 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7013 break;
7014
7015 case 14:
7016 //pivot and vh flip
7017 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7018 //return error cannot both pivot and vh flip
7019 break;
7020
7021 case 16:
7022 //lit
7023 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7024 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7025 break;
7026
7027 case 18:
7028 //pivot, lit
7029 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7030 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7031 break;
7032
7033 case 20:
7034 //lit + v flip
7035 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7036 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7037 break;
7038
7039 case 22:
7040 //Pivot, vflip, lit
7041 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7042 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7043 break;
7044
7045 case 24:
7046 //lit + h flip
7047 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7048 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7049 break;
7050
7051 case 26:
7052 //pivot + lit + hflip
7053 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7054 //return error cannot pivot, lit, and flip
7055 break;
7056
7057 case 28:
7058 //lit + vh flip
7059 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7060 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7061 break;
7062
7063 case 32: //gouraud
7064 //Probably not wort supporting.
7065 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7066 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7067 break;
7068
7069 case 0:
7070 //no effect
7071 611 stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
7072 611 break;
7073
7074
7075 default:
7076
7077 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7078
7079
7080 }
7081 611 } //end if not rotated
7082
7083
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if ( rot != 0 ) //if rotated
7084 {
7085 switch(mode)
7086 {
7087 case 1:
7088 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7089 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7090
7091 break;
7092
7093 case 2:
7094 //pivot?
7095 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7096 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7097 //Pivoting requires two more args
7098 break;
7099
7100 case 3:
7101 //pivot + trans
7102 //return an error, cannot both rotate and pivot
7103 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7104 break;
7105
7106 case 4:
7107 //flip v
7108 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7109 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7110 break;
7111
7112 case 5:
7113 //trans + v flip
7114 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7115 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7116 break;
7117
7118 case 6:
7119 //pivot + v flip
7120 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7121 //return an error, cannot both rotate and pivot
7122 break;
7123
7124 case 8:
7125 //flip h
7126 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7127 //return an error, cannot both rotate and flip H
7128 break;
7129
7130 case 9:
7131 //trans + h flip
7132 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7133 //return an error, cannot rotate and flip a trans sprite
7134 break;
7135
7136 case 10:
7137 //flip H and pivot
7138 //return error cannot pivot and h flip
7139 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7140 break;
7141
7142 case 12:
7143 //vh flip
7144 //return an error, cannot rotate and VH flip a trans sprite
7145 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7146 break;
7147
7148 case 13:
7149 //trans + vh flip
7150 //return an error, cannot rotate and VH flip a trans sprite
7151 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7152 break;
7153
7154 case 14:
7155 //pivot and vh flip
7156 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7157 //return error cannot both pivot and vh flip
7158 break;
7159
7160 case 16:
7161 //lit
7162 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7163 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7164 break;
7165
7166 case 18:
7167 //pivot, lit
7168 //return an error, cannot both rotate and pivot
7169 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7170 break;
7171
7172 case 20:
7173 //lit + vflip
7174 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7175 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7176 break;
7177
7178 case 22:
7179 //Pivot, vflip, lit
7180 //return an error, cannot both rotate and pivot
7181 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7182 break;
7183
7184 case 24:
7185 //lit + h flip
7186 //return an error, cannot both rotate and H flip
7187 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7188 break;
7189
7190 case 26:
7191 //pivot + lit + hflip
7192 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7193 //return error cannot pivot, lit, and flip
7194 break;
7195
7196 case 28:
7197 //lit + vh flip
7198 //return an error, cannot both rotate and VH flip
7199 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7200 break;
7201
7202 case 32: //gouraud
7203 //Probably not wort supporting.
7204 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7205 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7206 break;
7207
7208 case 0:
7209 //no effect.
7210 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7211 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7212 break;
7213
7214 default:
7215
7216 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7217
7218 }
7219 }
7220
7221 } //end if stretched, but not masked
7222 2086 }
7223 else //not stretched
7224 {
7225
7226
2/2
✓ Branch 0 taken 1982848 times.
✓ Branch 1 taken 77774 times.
2060622 if(masked) //if masked, but not stretched
7227 {
7228
7229
2/2
✓ Branch 0 taken 1005 times.
✓ Branch 1 taken 1981843 times.
1982848 if ( rot == 0 ) //if not rotated
7230 {
7231
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 19118 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1962725 times.
1981843 switch(mode)
7232 {
7233 case 1:
7234 //transparent
7235 19118 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7236 19118 draw_trans_sprite(destBMP, subBmp, dx, dy);
7237 19118 break;
7238
7239
7240 case 2:
7241 //pivot?
7242 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7243 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7244 //Pivoting requires two more args
7245 break;
7246
7247 case 3:
7248 //pivot + trans
7249 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7250 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7251 break;
7252
7253 case 4:
7254 //flip v
7255 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7256 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7257 break;
7258
7259 case 5:
7260 //trans + v flip
7261 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7262 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7263 break;
7264
7265 case 6:
7266 //pivot + v flip
7267 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7268 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7269 break;
7270
7271 case 8:
7272 //vlip h
7273 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7274 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7275 break;
7276
7277 case 9:
7278 //trans + h flip
7279 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7280 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7281 break;
7282
7283 case 10:
7284 //flip H and pivot
7285 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7286 //return error cannot pivot and h flip
7287 break;
7288
7289 case 12:
7290 //vh flip
7291 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7292 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7293 break;
7294
7295 case 13:
7296 //trans + vh flip
7297 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7298 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7299 break;
7300
7301 case 14:
7302 //pivot and vh flip
7303 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7304 //return error cannot both pivot and vh flip
7305 break;
7306
7307 case 16:
7308 //lit
7309 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7310 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7311 break;
7312
7313 case 18:
7314 //pivot, lit
7315 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7316 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7317 break;
7318
7319 case 20:
7320 //lit + v flip
7321 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7322 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7323 break;
7324
7325 case 22:
7326 //Pivot, vflip, lit
7327 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7328 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7329 break;
7330
7331 case 24:
7332 //lit + h flip
7333 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7334 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7335 break;
7336
7337 case 26:
7338 //pivot + lit + hflip
7339 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7340 //return error cannot pivot, lit, and flip
7341 break;
7342
7343 case 28:
7344 //lit + vh flip
7345 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7346 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7347 break;
7348
7349 case 32: //gouraud
7350 //Probably not wort supporting.
7351 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7352 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7353 break;
7354
7355 case 0:
7356 //no effect
7357 1962725 masked_blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7358 1962725 break;
7359
7360
7361 default:
7362
7363 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7364
7365
7366 }
7367 1981843 } //end if not rotated
7368
7369
2/2
✓ Branch 0 taken 1981843 times.
✓ Branch 1 taken 1005 times.
1982848 if ( rot != 0 ) //if rotated
7370 {
7371
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1005 times.
✗ Branch 21 not taken.
1005 switch(mode)
7372 {
7373 case 1:
7374 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //transparent
7375 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7376
7377 break;
7378
7379 case 2:
7380 //pivot?
7381 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7382 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7383 //Pivoting requires two more args
7384 break;
7385
7386 case 3:
7387 //pivot + trans
7388 //return an error, cannot both rotate and pivot
7389 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7390 break;
7391
7392 case 4:
7393 //flip v
7394 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7395 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7396 break;
7397
7398 case 5:
7399 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
7400 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7401 break;
7402
7403 case 6:
7404 //pivot + v flip
7405 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7406 //return an error, cannot both rotate and pivot
7407 break;
7408
7409 case 8:
7410 //flip h
7411 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7412 //return an error, cannot both rotate and flip H
7413 break;
7414
7415 case 9:
7416 //trans + h flip
7417 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7418 //return an error, cannot rotate and flip a trans sprite
7419 break;
7420
7421 case 10:
7422 //flip H and pivot
7423 //return error cannot pivot and h flip
7424 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7425 break;
7426
7427 case 12:
7428 //vh flip
7429 //return an error, cannot rotate and VH flip a trans sprite
7430 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7431 break;
7432
7433 case 13:
7434 //trans + vh flip
7435 //return an error, cannot rotate and VH flip a trans sprite
7436 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7437 break;
7438
7439 case 14:
7440 //pivot and vh flip
7441 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7442 //return error cannot both pivot and vh flip
7443 break;
7444
7445 case 16:
7446 //lit
7447 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7448 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7449 break;
7450
7451 case 18:
7452 //pivot, lit
7453 //return an error, cannot both rotate and pivot
7454 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7455 break;
7456
7457 case 20:
7458 //lit + vflip
7459 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7460 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7461 break;
7462
7463 case 22:
7464 //Pivot, vflip, lit
7465 //return an error, cannot both rotate and pivot
7466 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7467 break;
7468
7469 case 24:
7470 //lit + h flip
7471 //return an error, cannot both rotate and H flip
7472 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7473 break;
7474
7475 case 26:
7476 //pivot + lit + hflip
7477 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7478 //return error cannot pivot, lit, and flip
7479 break;
7480
7481 case 28:
7482 //lit + vh flip
7483 //return an error, cannot both rotate and VH flip
7484 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7485 break;
7486
7487 case 32: //gouraud
7488 //Probably not wort supporting.
7489 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7490 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7491 break;
7492
7493 case 0:
7494 //no effect.
7495 1005 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7496 1005 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7497 1005 break;
7498
7499 default:
7500
7501 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7502
7503 }
7504 1005 } //end rtated, masked
7505 1982848 } //end if masked
7506
7507 else //not masked, and not stretched; just blit
7508 {
7509
7510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77774 times.
77774 if ( rot == 0 ) //if not rotated
7511 {
7512
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 5714 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 72060 times.
77774 switch(mode)
7513 {
7514 case 1:
7515 //transparent
7516 5714 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7517 5714 draw_trans_sprite(destBMP, subBmp, dx, dy);
7518 5714 break;
7519
7520
7521 case 2:
7522 //pivot?
7523 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7524 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7525 //Pivoting requires two more args
7526 break;
7527
7528 case 3:
7529 //pivot + trans
7530 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7531 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7532 break;
7533
7534 case 4:
7535 //flip v
7536 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7537 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7538 break;
7539
7540 case 5:
7541 //trans + v flip
7542 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7543 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7544 break;
7545
7546 case 6:
7547 //pivot + v flip
7548 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7549 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7550 break;
7551
7552 case 8:
7553 //vlip h
7554 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7555 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7556 break;
7557
7558 case 9:
7559 //trans + h flip
7560 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7561 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7562 break;
7563
7564 case 10:
7565 //flip H and pivot
7566 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7567 //return error cannot pivot and h flip
7568 break;
7569
7570 case 12:
7571 //vh flip
7572 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7573 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7574 break;
7575
7576 case 13:
7577 //trans + vh flip
7578 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7579 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7580 break;
7581
7582 case 14:
7583 //pivot and vh flip
7584 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7585 //return error cannot both pivot and vh flip
7586 break;
7587
7588 case 16:
7589 //lit
7590 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7591 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7592 break;
7593
7594 case 18:
7595 //pivot, lit
7596 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7597 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7598 break;
7599
7600 case 20:
7601 //lit + v flip
7602 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7603 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7604 break;
7605
7606 case 22:
7607 //Pivot, vflip, lit
7608 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7609 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7610 break;
7611
7612 case 24:
7613 //lit + h flip
7614 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7615 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7616 break;
7617
7618 case 26:
7619 //pivot + lit + hflip
7620 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7621 //return error cannot pivot, lit, and flip
7622 break;
7623
7624 case 28:
7625 //lit + vh flip
7626 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7627 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7628 break;
7629
7630 case 32: //gouraud
7631 //Probably not wort supporting.
7632 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7633 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7634 break;
7635
7636 case 0:
7637 //no effect
7638 72060 blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7639 72060 break;
7640
7641
7642 default:
7643
7644 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7645
7646
7647 }
7648 77774 } //end if not rotated
7649
7650
1/2
✓ Branch 0 taken 77774 times.
✗ Branch 1 not taken.
77774 if ( rot != 0 ) //if rotated
7651 {
7652 switch(mode)
7653 {
7654 case 1:
7655 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);//transparent
7656 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7657
7658 break;
7659
7660 case 2:
7661 //pivot?
7662 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7663 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7664 //Pivoting requires two more args
7665 break;
7666
7667 case 3:
7668 //pivot + trans
7669 //return an error, cannot both rotate and pivot
7670 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7671 break;
7672
7673 case 4:
7674 //flip v
7675 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7676 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7677 break;
7678
7679 case 5:
7680 //trans + v flip
7681 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7682 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7683 break;
7684
7685 case 6:
7686 //pivot + v flip
7687 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7688 //return an error, cannot both rotate and pivot
7689 break;
7690
7691 case 8:
7692 //flip h
7693 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7694 //return an error, cannot both rotate and flip H
7695 break;
7696
7697 case 9:
7698 //trans + h flip
7699 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7700 //return an error, cannot rotate and flip a trans sprite
7701 break;
7702
7703 case 10:
7704 //flip H and pivot
7705 //return error cannot pivot and h flip
7706 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7707 break;
7708
7709 case 12:
7710 //vh flip
7711 //return an error, cannot rotate and VH flip a trans sprite
7712 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7713 break;
7714
7715 case 13:
7716 //trans + vh flip
7717 //return an error, cannot rotate and VH flip a trans sprite
7718 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7719 break;
7720
7721 case 14:
7722 //pivot and vh flip
7723 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7724 //return error cannot both pivot and vh flip
7725 break;
7726
7727 case 16:
7728 //lit
7729 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7730 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7731 break;
7732
7733 case 18:
7734 //pivot, lit
7735 //return an error, cannot both rotate and pivot
7736 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7737 break;
7738
7739 case 20:
7740 //lit + vflip
7741 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7742 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7743 break;
7744
7745 case 22:
7746 //Pivot, vflip, lit
7747 //return an error, cannot both rotate and pivot
7748 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7749 break;
7750
7751 case 24:
7752 //lit + h flip
7753 //return an error, cannot both rotate and H flip
7754 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7755 break;
7756
7757 case 26:
7758 //pivot + lit + hflip
7759 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7760 //return error cannot pivot, lit, and flip
7761 break;
7762
7763 case 28:
7764 //lit + vh flip
7765 //return an error, cannot both rotate and VH flip
7766 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7767 break;
7768
7769 case 32: //gouraud
7770 //Probably not wort supporting.
7771 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7772 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7773 break;
7774
7775 case 0:
7776 //no effect.
7777 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7778 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7779 break;
7780
7781 default:
7782
7783 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7784
7785 }
7786 } //end if rotated
7787 } //end if not masked
7788 } //end if not stretched
7789
7790 //cleanup
7791
2/2
✓ Branch 0 taken 27311 times.
✓ Branch 1 taken 2035397 times.
2062708 if(subBmp)
7792 {
7793 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
7794 27311 destroy_bitmap(subBmp);
7795 27311 }
7796
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 2061946 times.
2062708 if (sbmp != sourceBitmap)
7797 {
7798 762 destroy_bitmap(sbmp);
7799 762 }
7800 2062708 }
7801
7802
7803
7804 113653 void bmp_do_blittor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
7805 {
7806 /*
7807 //sdci[1]=layer
7808 //sdci[2]=bitmap target
7809 //
7810 // -2 is the current Render Target
7811 // -1, this is the screen (framebuf).
7812 // 0: Render target 0
7813 // 1: Render target 1
7814 // 2: Render target 2
7815 // 3: Render target 3
7816 // 4: Render target 4
7817 // 5: Render target 5
7818 // 6: Render target 6
7819 // Otherwise: The pointer to a bitmap.
7820
7821 //sdci[3]=sourcex
7822 //sdci[4]=sourcey
7823 //sdci[5]=sourcew
7824 //sdci[6]=sourceh
7825 //sdci[7]=destx
7826 //sdci[8]=desty
7827 //sdci[9]=destw
7828 //sdci[10]=desth
7829 //sdci[11]=rotation/angle
7830 //scdi[12] = pivot cx
7831 //sdci[13] = pivot cy
7832 //scdi[14] = effect flags
7833 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
7834
7835 // ZScript-side constant values:
7836 const int32_t BITDX_NORMAL = 0;
7837 const int32_t BITDX_TRANS = 1; //Translucent
7838 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
7839 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
7840 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
7841 //Note: Some modes cannot be combined. if a combination is not supported, an error
7842 // detailing this will be shown in allegro.log.
7843
7844 //scdi[15] = litcolour
7845 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7846 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
7847
7848 //sdci[16]=mask
7849
7850 */
7851
7852 113653 int32_t srcyoffset = yoffset, srcxoffset = xoffset;
7853
7854 113653 int32_t usr_bitmap_index = sdci[2];
7855 340955 auto [bitmapIndex, is_user_bitmap] = resolveScriptingBitmapId(usr_bitmap_index);
7856
7857 113653 int32_t sx = sdci[3]/10000;
7858 113653 int32_t sy = sdci[4]/10000;
7859 113653 int32_t sw = sdci[5]/10000;
7860 113653 int32_t sh = sdci[6]/10000;
7861 113653 int32_t dx = sdci[7]/10000;
7862 113653 int32_t dy = sdci[8]/10000;
7863 113653 int32_t dw = sdci[9]/10000;
7864 113653 int32_t dh = sdci[10]/10000;
7865 113653 float rot = sdci[11]/10000;
7866 113653 int32_t cx = sdci[12]/10000;
7867 113653 int32_t cy = sdci[13]/10000;
7868 113653 int32_t mode = sdci[14]/10000;
7869 113653 int32_t litcolour = sdci[15]/10000;
7870 113653 bool masked = (sdci[16] != 0);
7871
7872 113653 int32_t ref = 0;
7873
7874
2/2
✓ Branch 0 taken 113649 times.
✓ Branch 1 taken 4 times.
113653 if (get_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN))
7875 {
7876
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 113386 times.
113649 if (is_user_bitmap)
7877 113386 srcyoffset = 0;
7878
2/4
✓ Branch 0 taken 113649 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113649 times.
113649 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
7879
3/4
✓ Branch 0 taken 113649 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 113646 times.
113649 if ( (bitmapIndex) != -2 && (bitmapIndex) != -1 ) srcyoffset = 0; //Don't crop.
7880
7881 113649 dx += xoffset;
7882 113649 dy += yoffset;
7883
7884 113649 sx += srcxoffset;
7885 113649 sy += srcyoffset;
7886 113649 }
7887 else
7888 {
7889 4 dx += xoffset;
7890 4 dy += yoffset;
7891
7892 4 sx += secondary_draw_origin_xoff;
7893 4 sy += secondary_draw_origin_yoff;
7894 }
7895
7896 113653 ref = sdci[DRAWCMD_BMP_TARGET];
7897
7898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113653 times.
113653 if ( ref <= 0 )
7899 {
7900 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
7901 return;
7902 }
7903 113653 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
7904
1/2
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
113653 if(!sourceBitmap)
7905 {
7906 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
7907 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
7908 return;
7909 }
7910
7911 113653 BITMAP *destBMP=NULL;
7912
7913
3/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 113386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
113653 switch(bitmapIndex)
7914 {
7915 // Current render target (RT_CURRENT).
7916 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
7917 case -2:
7918 {
7919 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
7920 if ( curr_rt >= 0 && curr_rt < 7 )
7921 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
7922 else destBMP = bmp; //screen
7923 break;
7924 }
7925 case -1:
7926 7 destBMP = bmp; //this is framebuf, by default
7927 7 break;
7928 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
7929 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
7930 //destBMP = framebuf; //Drawing to the screen.
7931 //break;
7932
7933 //1 through 6 are the old system bitmaps (Render Targets)
7934 case 0:
7935 case 1:
7936 case 2:
7937 case 3:
7938 case 4:
7939 case 5:
7940 case 6:
7941 {
7942 //This gets a render target.
7943 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
7944
7945 520 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
7946 //sdci[18] = bitmapIndex;
7947 260 break;
7948 }
7949 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
7950 default:
7951 {
7952 113386 auto& usr_bitmap = scb.get(usr_bitmap_index);
7953 113386 destBMP = usr_bitmap.u_bmp;
7954 //sdci[18] = usr_bitmap_index;
7955
1/2
✓ Branch 0 taken 113386 times.
✗ Branch 1 not taken.
113386 if ( !usr_bitmap.u_bmp )
7956 {
7957 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
7958 break;
7959 }
7960 }
7961 113386 }
7962
7963
1/2
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
113653 if (!destBMP)
7964 {
7965 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
7966 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
7967 return;
7968 }
7969
7970
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 113343 times.
113653 bool stretched = (sw != dw || sh != dh);
7971
7972 113653 BITMAP* newDest = sourceBitmap;
7973 113653 BITMAP* newSource = destBMP; //Flip them.
7974
7975 113653 BITMAP* subBmp = 0;
7976
7977
2/4
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113653 times.
113653 if(rot != 0 || mode != 0)
7978 {
7979 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
7980 clear_bitmap(subBmp);
7981
7982 if(!subBmp)
7983 {
7984 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
7985 return;
7986 }
7987 }
7988
7989
3/4
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 113650 times.
113653 if (sx + sw > destBMP->w || sy + sh > destBMP->h)
7990 {
7991 3 newSource = create_bitmap_ex(8, sw, sh);
7992 3 clear_bitmap(newSource);
7993 3 blit(destBMP, newSource, sx, sy, 0, 0, std::min(destBMP->w-sx, sw), std::min(destBMP->h-sy, sh));
7994 3 sx = 0;
7995 3 sy = 0;
7996 3 }
7997 //dx = dx + xoffset; //don't do this here!
7998 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
7999
8000
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 113343 times.
113653 if(stretched)
8001 {
8002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if(masked)
8003 { //stretched and masked
8004 if ( rot == 0 )
8005 { //if not rotated
8006 switch(mode)
8007 {
8008 case 1:
8009 //transparent
8010 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8011 draw_trans_sprite(newDest, subBmp, dx, dy);
8012 break;
8013
8014
8015 case 2:
8016 //pivot?
8017 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8018 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8019 //Pivoting requires two more args
8020 break;
8021
8022 case 3:
8023 //pivot + trans
8024 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8025 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8026 break;
8027
8028 case 4:
8029 //flip v
8030 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8031 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8032 break;
8033
8034 case 5:
8035 //trans + v flip
8036 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8037 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8038 break;
8039
8040 case 6:
8041 //pivot + v flip
8042 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8043 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8044 break;
8045
8046 case 8:
8047 //vlip h
8048 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8049 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8050 break;
8051
8052 case 9:
8053 //trans + h flip
8054 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8055 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8056 break;
8057
8058 case 10:
8059 //flip H and pivot
8060 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8061 //return error cannot pivot and h flip
8062 break;
8063
8064 case 12:
8065 //vh flip
8066 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8067 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8068 break;
8069
8070 case 13:
8071 //trans + vh flip
8072 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8073 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8074 break;
8075
8076 case 14:
8077 //pivot and vh flip
8078 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8079 //return error cannot both pivot and vh flip
8080 break;
8081
8082 case 16:
8083 //lit
8084 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8085 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8086 break;
8087
8088 case 18:
8089 //pivot, lit
8090 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8091 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8092 break;
8093
8094 case 20:
8095 //lit + v flip
8096 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8097 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8098 break;
8099
8100 case 22:
8101 //Pivot, vflip, lit
8102 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8103 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8104 break;
8105
8106 case 24:
8107 //lit + h flip
8108 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8109 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8110 break;
8111
8112 case 26:
8113 //pivot + lit + hflip
8114 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8115 //return error cannot pivot, lit, and flip
8116 break;
8117
8118 case 28:
8119 //lit + vh flip
8120 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8121 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8122 break;
8123
8124 case 32: //gouraud
8125 //Probably not wort supporting.
8126 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8127 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8128 break;
8129
8130 case 0:
8131 //no effect
8132 masked_stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8133 break;
8134
8135
8136 default:
8137 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8138
8139
8140 }
8141 } //end if not rotated
8142
8143 if ( rot != 0 ) //if rotated
8144 {
8145 switch(mode)
8146 {
8147 case 1:
8148 //transparent
8149 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8150 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8151
8152 break;
8153
8154 case 2:
8155 //pivot?
8156 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8157 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8158 //Pivoting requires two more args
8159 break;
8160
8161 case 3:
8162 //pivot + trans
8163 //return an error, cannot both rotate and pivot
8164 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8165 break;
8166
8167 case 4:
8168 //flip v
8169 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8170 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8171 break;
8172
8173 case 5:
8174 //trans + v flip
8175 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8176 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8177 break;
8178
8179 case 6:
8180 //pivot + v flip
8181 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8182 //return an error, cannot both rotate and pivot
8183 break;
8184
8185 case 8:
8186 //flip h
8187 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8188 //return an error, cannot both rotate and flip H
8189 break;
8190
8191 case 9:
8192 //trans + h flip
8193 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8194 //return an error, cannot rotate and flip a trans sprite
8195 break;
8196
8197 case 10:
8198 //flip H and pivot
8199 //return error cannot pivot and h flip
8200 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8201 break;
8202
8203 case 12:
8204 //vh flip
8205 //return an error, cannot rotate and VH flip a trans sprite
8206 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8207 break;
8208
8209 case 13:
8210 //trans + vh flip
8211 //return an error, cannot rotate and VH flip a trans sprite
8212 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8213 break;
8214
8215 case 14:
8216 //pivot and vh flip
8217 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8218 //return error cannot both pivot and vh flip
8219 break;
8220
8221 case 16:
8222 //lit
8223 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8224 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8225 break;
8226
8227 case 18:
8228 //pivot, lit
8229 //return an error, cannot both rotate and pivot
8230 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8231 break;
8232
8233 case 20:
8234 //lit + vflip
8235 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8236 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8237 break;
8238
8239 case 22:
8240 //Pivot, vflip, lit
8241 //return an error, cannot both rotate and pivot
8242 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8243 break;
8244
8245 case 24:
8246 //lit + h flip
8247 //return an error, cannot both rotate and H flip
8248 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8249 break;
8250
8251 case 26:
8252 //pivot + lit + hflip
8253 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8254 //return error cannot pivot, lit, and flip
8255 break;
8256
8257 case 28:
8258 //lit + vh flip
8259 //return an error, cannot both rotate and VH flip
8260 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8261 break;
8262
8263 case 32: //gouraud
8264 //Probably not wort supporting.
8265 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8266 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8267 break;
8268
8269 case 0:
8270 //no effect.
8271 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8272 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8273 break;
8274
8275 default:
8276 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8277
8278 }
8279 }
8280 } //end if stretched and masked
8281
8282 else //stretched, not masked
8283 {
8284
8285
8286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if ( rot == 0 ) //if not rotated
8287 {
8288
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 310 times.
310 switch(mode)
8289 {
8290 case 1:
8291 //transparent
8292 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8293 draw_trans_sprite(newDest, subBmp, dx, dy);
8294 break;
8295
8296
8297 case 2:
8298 //pivot?
8299 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8300 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8301 //Pivoting requires two more args
8302 break;
8303
8304 case 3:
8305 //pivot + trans
8306 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8307 pivot_sprite_trans(newDest, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
8308 break;
8309
8310 case 4:
8311 //flip v
8312 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8313 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8314 break;
8315
8316 case 5:
8317 //trans + v flip
8318 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8319 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8320 break;
8321
8322 case 6:
8323 //pivot + v flip
8324 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8325 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8326 break;
8327
8328 case 8:
8329 //vlip h
8330 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8331 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8332 break;
8333
8334 case 9:
8335 //trans + h flip
8336 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8337 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8338 break;
8339
8340 case 10:
8341 //flip H and pivot
8342 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8343 //return error cannot pivot and h flip
8344 break;
8345
8346 case 12:
8347 //vh flip
8348 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8349 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8350 break;
8351
8352 case 13:
8353 //trans + vh flip
8354 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8355 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8356 break;
8357
8358 case 14:
8359 //pivot and vh flip
8360 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8361 //return error cannot both pivot and vh flip
8362 break;
8363
8364 case 16:
8365 //lit
8366 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8367 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8368 break;
8369
8370 case 18:
8371 //pivot, lit
8372 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8373 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8374 break;
8375
8376 case 20:
8377 //lit + v flip
8378 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8379 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8380 break;
8381
8382 case 22:
8383 //Pivot, vflip, lit
8384 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8385 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8386 break;
8387
8388 case 24:
8389 //lit + h flip
8390 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8391 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8392 break;
8393
8394 case 26:
8395 //pivot + lit + hflip
8396 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8397 //return error cannot pivot, lit, and flip
8398 break;
8399
8400 case 28:
8401 //lit + vh flip
8402 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8403 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8404 break;
8405
8406 case 32: //gouraud
8407 //Probably not wort supporting.
8408 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8409 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8410 break;
8411
8412 case 0:
8413 //no effect
8414 310 stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8415 310 break;
8416
8417
8418 default:
8419 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8420
8421
8422 }
8423 310 } //end if not rotated
8424
8425
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 if ( rot != 0 ) //if rotated
8426 {
8427 switch(mode)
8428 {
8429 case 1:
8430 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8431 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8432
8433 break;
8434
8435 case 2:
8436 //pivot?
8437 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8438 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8439 //Pivoting requires two more args
8440 break;
8441
8442 case 3:
8443 //pivot + trans
8444 //return an error, cannot both rotate and pivot
8445 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8446 break;
8447
8448 case 4:
8449 //flip v
8450 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8451 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8452 break;
8453
8454 case 5:
8455 //trans + v flip
8456 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8457 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8458 break;
8459
8460 case 6:
8461 //pivot + v flip
8462 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8463 //return an error, cannot both rotate and pivot
8464 break;
8465
8466 case 8:
8467 //flip h
8468 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8469 //return an error, cannot both rotate and flip H
8470 break;
8471
8472 case 9:
8473 //trans + h flip
8474 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8475 //return an error, cannot rotate and flip a trans sprite
8476 break;
8477
8478 case 10:
8479 //flip H and pivot
8480 //return error cannot pivot and h flip
8481 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8482 break;
8483
8484 case 12:
8485 //vh flip
8486 //return an error, cannot rotate and VH flip a trans sprite
8487 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8488 break;
8489
8490 case 13:
8491 //trans + vh flip
8492 //return an error, cannot rotate and VH flip a trans sprite
8493 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8494 break;
8495
8496 case 14:
8497 //pivot and vh flip
8498 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8499 //return error cannot both pivot and vh flip
8500 break;
8501
8502 case 16:
8503 //lit
8504 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8505 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8506 break;
8507
8508 case 18:
8509 //pivot, lit
8510 //return an error, cannot both rotate and pivot
8511 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8512 break;
8513
8514 case 20:
8515 //lit + vflip
8516 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8517 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8518 break;
8519
8520 case 22:
8521 //Pivot, vflip, lit
8522 //return an error, cannot both rotate and pivot
8523 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8524 break;
8525
8526 case 24:
8527 //lit + h flip
8528 //return an error, cannot both rotate and H flip
8529 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8530 break;
8531
8532 case 26:
8533 //pivot + lit + hflip
8534 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8535 //return error cannot pivot, lit, and flip
8536 break;
8537
8538 case 28:
8539 //lit + vh flip
8540 //return an error, cannot both rotate and VH flip
8541 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8542 break;
8543
8544 case 32: //gouraud
8545 //Probably not wort supporting.
8546 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8547 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8548 break;
8549
8550 case 0:
8551 //no effect.
8552 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8553 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8554 break;
8555
8556 default:
8557 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8558
8559 }
8560 }
8561
8562 } //end if stretched, but not masked
8563 310 }
8564 else //not stretched
8565 {
8566
8567
2/2
✓ Branch 0 taken 113326 times.
✓ Branch 1 taken 17 times.
113343 if(masked) //if masked, but not stretched
8568 {
8569
8570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113326 times.
113326 if ( rot == 0 ) //if not rotated
8571 {
8572
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 113326 times.
113326 switch(mode)
8573 {
8574 case 1:
8575 //transparent
8576 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8577 draw_trans_sprite(newDest, subBmp, dx, dy);
8578 break;
8579
8580
8581 case 2:
8582 //pivot?
8583 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8584 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8585 //Pivoting requires two more args
8586 break;
8587
8588 case 3:
8589 //pivot + trans
8590 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8591 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8592 break;
8593
8594 case 4:
8595 //flip v
8596 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8597 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8598 break;
8599
8600 case 5:
8601 //trans + v flip
8602 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8603 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8604 break;
8605
8606 case 6:
8607 //pivot + v flip
8608 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8609 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8610 break;
8611
8612 case 8:
8613 //vlip h
8614 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8615 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8616 break;
8617
8618 case 9:
8619 //trans + h flip
8620 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8621 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8622 break;
8623
8624 case 10:
8625 //flip H and pivot
8626 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8627 //return error cannot pivot and h flip
8628 break;
8629
8630 case 12:
8631 //vh flip
8632 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8633 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8634 break;
8635
8636 case 13:
8637 //trans + vh flip
8638 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8639 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8640 break;
8641
8642 case 14:
8643 //pivot and vh flip
8644 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8645 //return error cannot both pivot and vh flip
8646 break;
8647
8648 case 16:
8649 //lit
8650 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8651 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8652 break;
8653
8654 case 18:
8655 //pivot, lit
8656 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8657 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8658 break;
8659
8660 case 20:
8661 //lit + v flip
8662 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8663 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8664 break;
8665
8666 case 22:
8667 //Pivot, vflip, lit
8668 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8669 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8670 break;
8671
8672 case 24:
8673 //lit + h flip
8674 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8675 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8676 break;
8677
8678 case 26:
8679 //pivot + lit + hflip
8680 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8681 //return error cannot pivot, lit, and flip
8682 break;
8683
8684 case 28:
8685 //lit + vh flip
8686 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8687 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8688 break;
8689
8690 case 32: //gouraud
8691 //Probably not wort supporting.
8692 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8693 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8694 break;
8695
8696 case 0:
8697 //no effect
8698 113326 masked_blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
8699 113326 break;
8700
8701
8702 default:
8703 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8704
8705
8706 }
8707 113326 } //end if not rotated
8708
8709
1/2
✓ Branch 0 taken 113326 times.
✗ Branch 1 not taken.
113326 if ( rot != 0 ) //if rotated
8710 {
8711 switch(mode)
8712 {
8713 case 1:
8714 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //transparent
8715 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8716
8717 break;
8718
8719 case 2:
8720 //pivot?
8721 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8722 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8723 //Pivoting requires two more args
8724 break;
8725
8726 case 3:
8727 //pivot + trans
8728 //return an error, cannot both rotate and pivot
8729 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8730 break;
8731
8732 case 4:
8733 //flip v
8734 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8735 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8736 break;
8737
8738 case 5:
8739 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
8740 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8741 break;
8742
8743 case 6:
8744 //pivot + v flip
8745 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8746 //return an error, cannot both rotate and pivot
8747 break;
8748
8749 case 8:
8750 //flip h
8751 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8752 //return an error, cannot both rotate and flip H
8753 break;
8754
8755 case 9:
8756 //trans + h flip
8757 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8758 //return an error, cannot rotate and flip a trans sprite
8759 break;
8760
8761 case 10:
8762 //flip H and pivot
8763 //return error cannot pivot and h flip
8764 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8765 break;
8766
8767 case 12:
8768 //vh flip
8769 //return an error, cannot rotate and VH flip a trans sprite
8770 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8771 break;
8772
8773 case 13:
8774 //trans + vh flip
8775 //return an error, cannot rotate and VH flip a trans sprite
8776 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8777 break;
8778
8779 case 14:
8780 //pivot and vh flip
8781 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8782 //return error cannot both pivot and vh flip
8783 break;
8784
8785 case 16:
8786 //lit
8787 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8788 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8789 break;
8790
8791 case 18:
8792 //pivot, lit
8793 //return an error, cannot both rotate and pivot
8794 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8795 break;
8796
8797 case 20:
8798 //lit + vflip
8799 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8800 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8801 break;
8802
8803 case 22:
8804 //Pivot, vflip, lit
8805 //return an error, cannot both rotate and pivot
8806 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8807 break;
8808
8809 case 24:
8810 //lit + h flip
8811 //return an error, cannot both rotate and H flip
8812 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8813 break;
8814
8815 case 26:
8816 //pivot + lit + hflip
8817 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8818 //return error cannot pivot, lit, and flip
8819 break;
8820
8821 case 28:
8822 //lit + vh flip
8823 //return an error, cannot both rotate and VH flip
8824 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8825 break;
8826
8827 case 32: //gouraud
8828 //Probably not wort supporting.
8829 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8830 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8831 break;
8832
8833 case 0:
8834 //no effect.
8835 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8836 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8837 break;
8838
8839 default:
8840 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8841
8842 }
8843 } //end rtated, masked
8844 113326 } //end if masked
8845
8846 else //not masked, and not stretched; just blit
8847 {
8848
8849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if ( rot == 0 ) //if not rotated
8850 {
8851
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 17 times.
17 switch(mode)
8852 {
8853 case 1:
8854 //transparent
8855 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8856 draw_trans_sprite(newDest, subBmp, dx, dy);
8857 break;
8858
8859
8860 case 2:
8861 //pivot?
8862 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8863 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8864 //Pivoting requires two more args
8865 break;
8866
8867 case 3:
8868 //pivot + trans
8869 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8870 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8871 break;
8872
8873 case 4:
8874 //flip v
8875 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8876 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8877 break;
8878
8879 case 5:
8880 //trans + v flip
8881 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8882 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8883 break;
8884
8885 case 6:
8886 //pivot + v flip
8887 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8888 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8889 break;
8890
8891 case 8:
8892 //vlip h
8893 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8894 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8895 break;
8896
8897 case 9:
8898 //trans + h flip
8899 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8900 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8901 break;
8902
8903 case 10:
8904 //flip H and pivot
8905 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8906 //return error cannot pivot and h flip
8907 break;
8908
8909 case 12:
8910 //vh flip
8911 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8912 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8913 break;
8914
8915 case 13:
8916 //trans + vh flip
8917 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8918 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8919 break;
8920
8921 case 14:
8922 //pivot and vh flip
8923 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8924 //return error cannot both pivot and vh flip
8925 break;
8926
8927 case 16:
8928 //lit
8929 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8930 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8931 break;
8932
8933 case 18:
8934 //pivot, lit
8935 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8936 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8937 break;
8938
8939 case 20:
8940 //lit + v flip
8941 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8942 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8943 break;
8944
8945 case 22:
8946 //Pivot, vflip, lit
8947 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8948 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8949 break;
8950
8951 case 24:
8952 //lit + h flip
8953 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8954 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8955 break;
8956
8957 case 26:
8958 //pivot + lit + hflip
8959 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8960 //return error cannot pivot, lit, and flip
8961 break;
8962
8963 case 28:
8964 //lit + vh flip
8965 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8966 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8967 break;
8968
8969 case 32: //gouraud
8970 //Probably not wort supporting.
8971 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8972 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8973 break;
8974
8975 case 0:
8976 //no effect
8977 17 blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
8978 17 break;
8979
8980
8981 default:
8982 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8983
8984
8985 }
8986 17 } //end if not rotated
8987
8988
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if ( rot != 0 ) //if rotated
8989 {
8990 switch(mode)
8991 {
8992 case 1:
8993 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);//transparent
8994 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8995
8996 break;
8997
8998 case 2:
8999 //pivot?
9000 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9001 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9002 //Pivoting requires two more args
9003 break;
9004
9005 case 3:
9006 //pivot + trans
9007 //return an error, cannot both rotate and pivot
9008 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9009 break;
9010
9011 case 4:
9012 //flip v
9013 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9014 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9015 break;
9016
9017 case 5:
9018 //trans + v flip
9019 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9020 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9021 break;
9022
9023 case 6:
9024 //pivot + v flip
9025 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9026 //return an error, cannot both rotate and pivot
9027 break;
9028
9029 case 8:
9030 //flip h
9031 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
9032 //return an error, cannot both rotate and flip H
9033 break;
9034
9035 case 9:
9036 //trans + h flip
9037 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
9038 //return an error, cannot rotate and flip a trans sprite
9039 break;
9040
9041 case 10:
9042 //flip H and pivot
9043 //return error cannot pivot and h flip
9044 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
9045 break;
9046
9047 case 12:
9048 //vh flip
9049 //return an error, cannot rotate and VH flip a trans sprite
9050 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9051 break;
9052
9053 case 13:
9054 //trans + vh flip
9055 //return an error, cannot rotate and VH flip a trans sprite
9056 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9057 break;
9058
9059 case 14:
9060 //pivot and vh flip
9061 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9062 //return error cannot both pivot and vh flip
9063 break;
9064
9065 case 16:
9066 //lit
9067 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9068 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9069 break;
9070
9071 case 18:
9072 //pivot, lit
9073 //return an error, cannot both rotate and pivot
9074 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9075 break;
9076
9077 case 20:
9078 //lit + vflip
9079 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9080 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9081 break;
9082
9083 case 22:
9084 //Pivot, vflip, lit
9085 //return an error, cannot both rotate and pivot
9086 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9087 break;
9088
9089 case 24:
9090 //lit + h flip
9091 //return an error, cannot both rotate and H flip
9092 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
9093 break;
9094
9095 case 26:
9096 //pivot + lit + hflip
9097 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
9098 //return error cannot pivot, lit, and flip
9099 break;
9100
9101 case 28:
9102 //lit + vh flip
9103 //return an error, cannot both rotate and VH flip
9104 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
9105 break;
9106
9107 case 32: //gouraud
9108 //Probably not wort supporting.
9109 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9110 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9111 break;
9112
9113 case 0:
9114 //no effect.
9115 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9116 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9117 break;
9118
9119 default:
9120 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
9121
9122 }
9123 } //end if rotated
9124 } //end if not masked
9125 } //end if not stretched
9126
9127 //cleanup
9128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113653 times.
113653 if(subBmp)
9129 {
9130 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
9131 destroy_bitmap(subBmp);
9132 }
9133
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 113650 times.
113653 if(newSource != destBMP)
9134 {
9135 3 destroy_bitmap(newSource);
9136 3 }
9137 113653 }
9138
9139 void do_tileblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool is_bmp, char const* funcstr)
9140 {
9141 /*
9142 //sdci[1]=layer
9143 //sdci[2]=tile
9144 //sdci[3]=cset
9145 //sdci[4]=sourcex
9146 //sdci[5]=sourcey
9147 //sdci[6]=sourcew
9148 //sdci[7]=sourceh
9149 //sdci[8]=destx
9150 //sdci[9]=desty
9151 //sdci[10]=destw
9152 //sdci[11]=desth
9153 //sdci[12]=rotation/angle
9154 //scdi[13] = pivot cx
9155 //sdci[14] = pivot cy
9156 //scdi[15] = effect flags
9157
9158 // ZScript-side constant values:
9159 const int32_t BITDX_NORMAL = 0;
9160 const int32_t BITDX_TRANS = 1; //Translucent
9161 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
9162 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
9163 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
9164 //Note: Some modes cannot be combined. if a combination is not supported, an error
9165 // detailing this will be shown in allegro.log.
9166
9167 //scdi[16] = litcolour
9168 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9169 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
9170
9171 //sdci[17]=mask
9172 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
9173
9174 */
9175
9176 int32_t tile = sdci[2]/10000;
9177 int32_t cset = WRAP_CS(sdci[3]/10000);
9178
9179 int32_t sx = sdci[4]/10000;
9180 int32_t sy = sdci[5]/10000;
9181 int32_t sw = sdci[6]/10000;
9182 //Z_scripterrlog("sh is: %d\n",sdci[5]/10000);
9183 int32_t sh = sdci[7]/10000;
9184 //Z_scripterrlog("sh is: %d\n",sdci[6]/10000);
9185 int32_t dx = sdci[8]/10000;
9186 int32_t dy = sdci[9]/10000;
9187 int32_t dw = sdci[10]/10000;
9188 int32_t dh = sdci[11]/10000;
9189 float rot = sdci[12]/10000;
9190 int32_t cx = sdci[13]/10000;
9191 int32_t cy = sdci[14]/10000;
9192 int32_t mode = sdci[15]/10000;
9193 int32_t litcolour = sdci[16]/10000;
9194 bool masked = (sdci[17] != 0);
9195
9196 int32_t ref = 0;
9197
9198 if ( is_bmp && (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
9199 //Do we need to also check the render target and do the same thing if the
9200 //dest == -2 and the render target is not RT_SCREEN?
9201 dx += xoffset;
9202 dy += yoffset;
9203
9204 BITMAP *destbmp = nullptr;
9205 if(is_bmp)
9206 {
9207 ref = sdci[DRAWCMD_BMP_TARGET];
9208
9209 if ( ref <= 0 )
9210 {
9211 Z_scripterrlog("%s wanted to use to an invalid dest bitmap id: %d. Aborting.\n", funcstr, ref);
9212 return;
9213 }
9214 destbmp = resolveScriptingBitmap(ref);
9215 if(!destbmp)
9216 {
9217 Z_message("Warning: %s dest bitmap %d contains invalid data or is not initialized.\n", ref);
9218 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
9219 return;
9220 }
9221 }
9222 else destbmp = bmp;
9223
9224 bool stretched = (sw != dw || sh != dh);
9225
9226 BITMAP* srcbmp = create_bitmap_ex(8, sw, sh);
9227 //Draw tiles to srcbmp
9228 {
9229 clear_bitmap(srcbmp);
9230 int tx = 0, ty = 0;
9231 if(sx < 0)
9232 tx = (sx-15)/16;
9233 else if(sx > 15)
9234 tx = sx/16;
9235 if(sy < 0)
9236 ty = (sy-15)/16;
9237 else if(sy > 15)
9238 ty = sy/16;
9239
9240 int gxoff = -wrap(sx,0,15), gyoff = -wrap(sy,0,15);
9241 for(int ix = 0; ix <= sw; ix += 16)
9242 {
9243 for(int iy = 0; iy <= sh; iy += 16)
9244 {
9245 int t = tile+(tx+ix/16);
9246 int rowdiff = TILEROW(t) - TILEROW(tile);
9247 t += rowdiff * (sh/16) * TILES_PER_ROW;
9248 t += (ty+iy/16)*TILES_PER_ROW;
9249 overtile16(srcbmp, t, ix+gxoff, iy+gyoff, cset, 0);
9250 }
9251 }
9252
9253 sx = sy = 0;
9254 }
9255
9256 BITMAP* subBmp = nullptr;
9257
9258 if(rot != 0 || mode != 0)
9259 {
9260 subBmp = create_bitmap_ex(8,destbmp->w, destbmp->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
9261 clear_bitmap(subBmp);
9262
9263 if(!subBmp)
9264 {
9265 Z_scripterrlog("%s failed to create a sub-bitmap to use for %s. Aborting.\n", funcstr, "rotation");
9266 return;
9267 }
9268 }
9269
9270 //dx = dx + xoffset; //don't do this here!
9271 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
9272
9273 if(stretched)
9274 {
9275 if(masked)
9276 { //stretched and masked
9277 if ( rot == 0 )
9278 { //if not rotated
9279 switch(mode)
9280 {
9281 case 1:
9282 //transparent
9283 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9284 draw_trans_sprite(destbmp, subBmp, dx, dy);
9285 break;
9286
9287
9288 case 2:
9289 //pivot?
9290 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9291 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9292 //Pivoting requires two more args
9293 break;
9294
9295 case 3:
9296 //pivot + trans
9297 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9298 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9299 break;
9300
9301 case 4:
9302 //flip v
9303 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9304 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9305 break;
9306
9307 case 5:
9308 //trans + v flip
9309 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9310 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9311 break;
9312
9313 case 6:
9314 //pivot + v flip
9315 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9316 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9317 break;
9318
9319 case 8:
9320 //vlip h
9321 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9322 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9323 break;
9324
9325 case 9:
9326 //trans + h flip
9327 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9328 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9329 break;
9330
9331 case 10:
9332 //flip H and pivot
9333 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9334 //return error cannot pivot and h flip
9335 break;
9336
9337 case 12:
9338 //vh flip
9339 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9340 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9341 break;
9342
9343 case 13:
9344 //trans + vh flip
9345 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9346 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9347 break;
9348
9349 case 14:
9350 //pivot and vh flip
9351 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9352 //return error cannot both pivot and vh flip
9353 break;
9354
9355 case 16:
9356 //lit
9357 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9358 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9359 break;
9360
9361 case 18:
9362 //pivot, lit
9363 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9364 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9365 break;
9366
9367 case 20:
9368 //lit + v flip
9369 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9370 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9371 break;
9372
9373 case 22:
9374 //Pivot, vflip, lit
9375 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9376 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9377 break;
9378
9379 case 24:
9380 //lit + h flip
9381 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9382 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9383 break;
9384
9385 case 26:
9386 //pivot + lit + hflip
9387 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9388 //return error cannot pivot, lit, and flip
9389 break;
9390
9391 case 28:
9392 //lit + vh flip
9393 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9394 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9395 break;
9396
9397 case 32: //gouraud
9398 //Probably not wort supporting.
9399 //masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9400 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9401 break;
9402
9403 case 0:
9404 //no effect
9405 masked_stretch_blit(srcbmp, destbmp, sx, sy, sw, sh, dx, dy, dw, dh);
9406 break;
9407
9408
9409 default:
9410 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9411
9412
9413 }
9414 } //end if not rotated
9415
9416 if ( rot != 0 ) //if rotated
9417 {
9418 switch(mode)
9419 {
9420 case 1:
9421 //transparent
9422 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9423 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9424
9425 break;
9426
9427 case 2:
9428 //pivot?
9429 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9430 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9431 //Pivoting requires two more args
9432 break;
9433
9434 case 3:
9435 //pivot + trans
9436 //return an error, cannot both rotate and pivot
9437 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9438 break;
9439
9440 case 4:
9441 //flip v
9442 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9443 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9444 break;
9445
9446 case 5:
9447 //trans + v flip
9448 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9449 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9450 break;
9451
9452 case 6:
9453 //pivot + v flip
9454 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9455 //return an error, cannot both rotate and pivot
9456 break;
9457
9458 case 8:
9459 //flip h
9460 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9461 //return an error, cannot both rotate and flip H
9462 break;
9463
9464 case 9:
9465 //trans + h flip
9466 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
9467 //return an error, cannot rotate and flip a trans sprite
9468 break;
9469
9470 case 10:
9471 //flip H and pivot
9472 //return error cannot pivot and h flip
9473 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9474 break;
9475
9476 case 12:
9477 //vh flip
9478 //return an error, cannot rotate and VH flip a trans sprite
9479 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9480 break;
9481
9482 case 13:
9483 //trans + vh flip
9484 //return an error, cannot rotate and VH flip a trans sprite
9485 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9486 break;
9487
9488 case 14:
9489 //pivot and vh flip
9490 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9491 //return error cannot both pivot and vh flip
9492 break;
9493
9494 case 16:
9495 //lit
9496 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9497 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9498 break;
9499
9500 case 18:
9501 //pivot, lit
9502 //return an error, cannot both rotate and pivot
9503 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9504 break;
9505
9506 case 20:
9507 //lit + vflip
9508 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9509 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9510 break;
9511
9512 case 22:
9513 //Pivot, vflip, lit
9514 //return an error, cannot both rotate and pivot
9515 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9516 break;
9517
9518 case 24:
9519 //lit + h flip
9520 //return an error, cannot both rotate and H flip
9521 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9522 break;
9523
9524 case 26:
9525 //pivot + lit + hflip
9526 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
9527 //return error cannot pivot, lit, and flip
9528 break;
9529
9530 case 28:
9531 //lit + vh flip
9532 //return an error, cannot both rotate and VH flip
9533 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9534 break;
9535
9536 case 32: //gouraud
9537 //Probably not wort supporting.
9538 //masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9539 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9540 break;
9541
9542 case 0:
9543 //no effect.
9544 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9545 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9546 break;
9547
9548 default:
9549 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9550
9551 }
9552 }
9553 } //end if stretched and masked
9554
9555 else //stretched, not masked
9556 {
9557
9558
9559 if ( rot == 0 ) //if not rotated
9560 {
9561 switch(mode)
9562 {
9563 case 1:
9564 //transparent
9565 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9566 draw_trans_sprite(destbmp, subBmp, dx, dy);
9567 break;
9568
9569
9570 case 2:
9571 //pivot?
9572 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9573 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9574 //Pivoting requires two more args
9575 break;
9576
9577 case 3:
9578 //pivot + trans
9579 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9580 pivot_sprite_trans(destbmp, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
9581 break;
9582
9583 case 4:
9584 //flip v
9585 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9586 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9587 break;
9588
9589 case 5:
9590 //trans + v flip
9591 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9592 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9593 break;
9594
9595 case 6:
9596 //pivot + v flip
9597 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9598 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9599 break;
9600
9601 case 8:
9602 //vlip h
9603 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9604 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9605 break;
9606
9607 case 9:
9608 //trans + h flip
9609 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9610 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9611 break;
9612
9613 case 10:
9614 //flip H and pivot
9615 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9616 //return error cannot pivot and h flip
9617 break;
9618
9619 case 12:
9620 //vh flip
9621 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9622 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9623 break;
9624
9625 case 13:
9626 //trans + vh flip
9627 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9628 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9629 break;
9630
9631 case 14:
9632 //pivot and vh flip
9633 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9634 //return error cannot both pivot and vh flip
9635 break;
9636
9637 case 16:
9638 //lit
9639 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9640 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9641 break;
9642
9643 case 18:
9644 //pivot, lit
9645 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9646 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9647 break;
9648
9649 case 20:
9650 //lit + v flip
9651 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9652 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9653 break;
9654
9655 case 22:
9656 //Pivot, vflip, lit
9657 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9658 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9659 break;
9660
9661 case 24:
9662 //lit + h flip
9663 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9664 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9665 break;
9666
9667 case 26:
9668 //pivot + lit + hflip
9669 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9670 //return error cannot pivot, lit, and flip
9671 break;
9672
9673 case 28:
9674 //lit + vh flip
9675 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9676 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9677 break;
9678
9679 case 32: //gouraud
9680 //Probably not wort supporting.
9681 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9682 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9683 break;
9684
9685 case 0:
9686 //no effect
9687 stretch_blit(srcbmp, destbmp, sx, sy, sw, sh, dx, dy, dw, dh);
9688 break;
9689
9690
9691 default:
9692 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9693
9694
9695 }
9696 } //end if not rotated
9697
9698 if ( rot != 0 ) //if rotated
9699 {
9700 switch(mode)
9701 {
9702 case 1:
9703 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9704 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9705
9706 break;
9707
9708 case 2:
9709 //pivot?
9710 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9711 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9712 //Pivoting requires two more args
9713 break;
9714
9715 case 3:
9716 //pivot + trans
9717 //return an error, cannot both rotate and pivot
9718 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9719 break;
9720
9721 case 4:
9722 //flip v
9723 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9724 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9725 break;
9726
9727 case 5:
9728 //trans + v flip
9729 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9730 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9731 break;
9732
9733 case 6:
9734 //pivot + v flip
9735 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9736 //return an error, cannot both rotate and pivot
9737 break;
9738
9739 case 8:
9740 //flip h
9741 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9742 //return an error, cannot both rotate and flip H
9743 break;
9744
9745 case 9:
9746 //trans + h flip
9747 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
9748 //return an error, cannot rotate and flip a trans sprite
9749 break;
9750
9751 case 10:
9752 //flip H and pivot
9753 //return error cannot pivot and h flip
9754 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9755 break;
9756
9757 case 12:
9758 //vh flip
9759 //return an error, cannot rotate and VH flip a trans sprite
9760 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9761 break;
9762
9763 case 13:
9764 //trans + vh flip
9765 //return an error, cannot rotate and VH flip a trans sprite
9766 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9767 break;
9768
9769 case 14:
9770 //pivot and vh flip
9771 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9772 //return error cannot both pivot and vh flip
9773 break;
9774
9775 case 16:
9776 //lit
9777 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9778 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9779 break;
9780
9781 case 18:
9782 //pivot, lit
9783 //return an error, cannot both rotate and pivot
9784 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9785 break;
9786
9787 case 20:
9788 //lit + vflip
9789 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9790 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9791 break;
9792
9793 case 22:
9794 //Pivot, vflip, lit
9795 //return an error, cannot both rotate and pivot
9796 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9797 break;
9798
9799 case 24:
9800 //lit + h flip
9801 //return an error, cannot both rotate and H flip
9802 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9803 break;
9804
9805 case 26:
9806 //pivot + lit + hflip
9807 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
9808 //return error cannot pivot, lit, and flip
9809 break;
9810
9811 case 28:
9812 //lit + vh flip
9813 //return an error, cannot both rotate and VH flip
9814 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9815 break;
9816
9817 case 32: //gouraud
9818 //Probably not wort supporting.
9819 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9820 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9821 break;
9822
9823 case 0:
9824 //no effect.
9825 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9826 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9827 break;
9828
9829 default:
9830 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9831
9832 }
9833 }
9834
9835 } //end if stretched, but not masked
9836 }
9837 else //not stretched
9838 {
9839
9840 if(masked) //if masked, but not stretched
9841 {
9842
9843 if ( rot == 0 ) //if not rotated
9844 {
9845 switch(mode)
9846 {
9847 case 1:
9848 //transparent
9849 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9850 draw_trans_sprite(destbmp, subBmp, dx, dy);
9851 break;
9852
9853
9854 case 2:
9855 //pivot?
9856 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9857 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9858 //Pivoting requires two more args
9859 break;
9860
9861 case 3:
9862 //pivot + trans
9863 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9864 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9865 break;
9866
9867 case 4:
9868 //flip v
9869 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9870 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9871 break;
9872
9873 case 5:
9874 //trans + v flip
9875 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9876 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9877 break;
9878
9879 case 6:
9880 //pivot + v flip
9881 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9882 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9883 break;
9884
9885 case 8:
9886 //vlip h
9887 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9888 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9889 break;
9890
9891 case 9:
9892 //trans + h flip
9893 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9894 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9895 break;
9896
9897 case 10:
9898 //flip H and pivot
9899 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9900 //return error cannot pivot and h flip
9901 break;
9902
9903 case 12:
9904 //vh flip
9905 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9906 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9907 break;
9908
9909 case 13:
9910 //trans + vh flip
9911 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9912 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9913 break;
9914
9915 case 14:
9916 //pivot and vh flip
9917 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9918 //return error cannot both pivot and vh flip
9919 break;
9920
9921 case 16:
9922 //lit
9923 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9924 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9925 break;
9926
9927 case 18:
9928 //pivot, lit
9929 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9930 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9931 break;
9932
9933 case 20:
9934 //lit + v flip
9935 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9936 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9937 break;
9938
9939 case 22:
9940 //Pivot, vflip, lit
9941 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9942 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9943 break;
9944
9945 case 24:
9946 //lit + h flip
9947 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9948 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9949 break;
9950
9951 case 26:
9952 //pivot + lit + hflip
9953 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9954 //return error cannot pivot, lit, and flip
9955 break;
9956
9957 case 28:
9958 //lit + vh flip
9959 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9960 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9961 break;
9962
9963 case 32: //gouraud
9964 //Probably not wort supporting.
9965 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9966 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9967 break;
9968
9969 case 0:
9970 //no effect
9971 masked_blit(srcbmp, destbmp, sx, sy, dx, dy, dw, dh);
9972 break;
9973
9974
9975 default:
9976 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9977
9978
9979 }
9980 } //end if not rotated
9981
9982 if ( rot != 0 ) //if rotated
9983 {
9984 switch(mode)
9985 {
9986 case 1:
9987 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh); //transparent
9988 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9989
9990 break;
9991
9992 case 2:
9993 //pivot?
9994 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9995 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9996 //Pivoting requires two more args
9997 break;
9998
9999 case 3:
10000 //pivot + trans
10001 //return an error, cannot both rotate and pivot
10002 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10003 break;
10004
10005 case 4:
10006 //flip v
10007 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10008 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10009 break;
10010
10011 case 5:
10012 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
10013 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10014 break;
10015
10016 case 6:
10017 //pivot + v flip
10018 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10019 //return an error, cannot both rotate and pivot
10020 break;
10021
10022 case 8:
10023 //flip h
10024 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10025 //return an error, cannot both rotate and flip H
10026 break;
10027
10028 case 9:
10029 //trans + h flip
10030 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
10031 //return an error, cannot rotate and flip a trans sprite
10032 break;
10033
10034 case 10:
10035 //flip H and pivot
10036 //return error cannot pivot and h flip
10037 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10038 break;
10039
10040 case 12:
10041 //vh flip
10042 //return an error, cannot rotate and VH flip a trans sprite
10043 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10044 break;
10045
10046 case 13:
10047 //trans + vh flip
10048 //return an error, cannot rotate and VH flip a trans sprite
10049 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10050 break;
10051
10052 case 14:
10053 //pivot and vh flip
10054 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10055 //return error cannot both pivot and vh flip
10056 break;
10057
10058 case 16:
10059 //lit
10060 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10061 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10062 break;
10063
10064 case 18:
10065 //pivot, lit
10066 //return an error, cannot both rotate and pivot
10067 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10068 break;
10069
10070 case 20:
10071 //lit + vflip
10072 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10073 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10074 break;
10075
10076 case 22:
10077 //Pivot, vflip, lit
10078 //return an error, cannot both rotate and pivot
10079 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10080 break;
10081
10082 case 24:
10083 //lit + h flip
10084 //return an error, cannot both rotate and H flip
10085 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10086 break;
10087
10088 case 26:
10089 //pivot + lit + hflip
10090 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
10091 //return error cannot pivot, lit, and flip
10092 break;
10093
10094 case 28:
10095 //lit + vh flip
10096 //return an error, cannot both rotate and VH flip
10097 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10098 break;
10099
10100 case 32: //gouraud
10101 //Probably not wort supporting.
10102 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
10103 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10104 break;
10105
10106 case 0:
10107 //no effect.
10108 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10109 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10110 break;
10111
10112 default:
10113 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10114
10115 }
10116 } //end rtated, masked
10117 } //end if masked
10118
10119 else //not masked, and not stretched; just blit
10120 {
10121
10122 if ( rot == 0 ) //if not rotated
10123 {
10124 switch(mode)
10125 {
10126 case 1:
10127 //transparent
10128 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10129 draw_trans_sprite(destbmp, subBmp, dx, dy);
10130 break;
10131
10132
10133 case 2:
10134 //pivot?
10135 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10136 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10137 //Pivoting requires two more args
10138 break;
10139
10140 case 3:
10141 //pivot + trans
10142 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10143 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10144 break;
10145
10146 case 4:
10147 //flip v
10148 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10149 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
10150 break;
10151
10152 case 5:
10153 //trans + v flip
10154 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10155 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
10156 break;
10157
10158 case 6:
10159 //pivot + v flip
10160 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10161 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10162 break;
10163
10164 case 8:
10165 //vlip h
10166 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10167 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
10168 break;
10169
10170 case 9:
10171 //trans + h flip
10172 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10173 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
10174 break;
10175
10176 case 10:
10177 //flip H and pivot
10178 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10179 //return error cannot pivot and h flip
10180 break;
10181
10182 case 12:
10183 //vh flip
10184 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10185 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
10186 break;
10187
10188 case 13:
10189 //trans + vh flip
10190 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10191 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
10192 break;
10193
10194 case 14:
10195 //pivot and vh flip
10196 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10197 //return error cannot both pivot and vh flip
10198 break;
10199
10200 case 16:
10201 //lit
10202 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10203 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
10204 break;
10205
10206 case 18:
10207 //pivot, lit
10208 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10209 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
10210 break;
10211
10212 case 20:
10213 //lit + v flip
10214 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10215 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
10216 break;
10217
10218 case 22:
10219 //Pivot, vflip, lit
10220 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10221 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
10222 break;
10223
10224 case 24:
10225 //lit + h flip
10226 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10227 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
10228 break;
10229
10230 case 26:
10231 //pivot + lit + hflip
10232 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
10233 //return error cannot pivot, lit, and flip
10234 break;
10235
10236 case 28:
10237 //lit + vh flip
10238 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10239 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
10240 break;
10241
10242 case 32: //gouraud
10243 //Probably not wort supporting.
10244 //blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10245 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10246 break;
10247
10248 case 0:
10249 //no effect
10250 blit(srcbmp, destbmp, sx, sy, dx, dy, dw, dh);
10251 break;
10252
10253
10254 default:
10255 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10256
10257
10258 }
10259 } //end if not rotated
10260
10261 if ( rot != 0 ) //if rotated
10262 {
10263 switch(mode)
10264 {
10265 case 1:
10266 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);//transparent
10267 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10268
10269 break;
10270
10271 case 2:
10272 //pivot?
10273 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10274 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10275 //Pivoting requires two more args
10276 break;
10277
10278 case 3:
10279 //pivot + trans
10280 //return an error, cannot both rotate and pivot
10281 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10282 break;
10283
10284 case 4:
10285 //flip v
10286 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10287 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10288 break;
10289
10290 case 5:
10291 //trans + v flip
10292 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10293 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10294 break;
10295
10296 case 6:
10297 //pivot + v flip
10298 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10299 //return an error, cannot both rotate and pivot
10300 break;
10301
10302 case 8:
10303 //flip h
10304 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10305 //return an error, cannot both rotate and flip H
10306 break;
10307
10308 case 9:
10309 //trans + h flip
10310 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
10311 //return an error, cannot rotate and flip a trans sprite
10312 break;
10313
10314 case 10:
10315 //flip H and pivot
10316 //return error cannot pivot and h flip
10317 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10318 break;
10319
10320 case 12:
10321 //vh flip
10322 //return an error, cannot rotate and VH flip a trans sprite
10323 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10324 break;
10325
10326 case 13:
10327 //trans + vh flip
10328 //return an error, cannot rotate and VH flip a trans sprite
10329 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10330 break;
10331
10332 case 14:
10333 //pivot and vh flip
10334 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10335 //return error cannot both pivot and vh flip
10336 break;
10337
10338 case 16:
10339 //lit
10340 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10341 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10342 break;
10343
10344 case 18:
10345 //pivot, lit
10346 //return an error, cannot both rotate and pivot
10347 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10348 break;
10349
10350 case 20:
10351 //lit + vflip
10352 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10353 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10354 break;
10355
10356 case 22:
10357 //Pivot, vflip, lit
10358 //return an error, cannot both rotate and pivot
10359 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10360 break;
10361
10362 case 24:
10363 //lit + h flip
10364 //return an error, cannot both rotate and H flip
10365 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10366 break;
10367
10368 case 26:
10369 //pivot + lit + hflip
10370 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
10371 //return error cannot pivot, lit, and flip
10372 break;
10373
10374 case 28:
10375 //lit + vh flip
10376 //return an error, cannot both rotate and VH flip
10377 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10378 break;
10379
10380 case 32: //gouraud
10381 //Probably not wort supporting.
10382 //blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10383 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10384 break;
10385
10386 case 0:
10387 //no effect.
10388 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10389 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10390 break;
10391
10392 default:
10393 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10394
10395 }
10396 } //end if rotated
10397 } //end if not masked
10398 } //end if not stretched
10399
10400 //cleanup
10401 if(subBmp)
10402 {
10403 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
10404 destroy_bitmap(subBmp);
10405 }
10406 destroy_bitmap(srcbmp);
10407 }
10408
10409 void do_comboblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool is_bmp)
10410 {
10411 //sdci[2]: combo -> tile
10412 int cid = sdci[2]/10000;
10413 if(unsigned(cid) >= MAXCOMBOS)
10414 {
10415 Z_scripterrlog("ComboBlit tried to draw invalid combo id '%d'\n", cid);
10416 return;
10417 }
10418 sdci[2] = GET_DRAWING_COMBO(cid).tile * 10000;
10419 do_tileblit(bmp, sdci, xoffset, yoffset, is_bmp, "ComboBlit()");
10420 }
10421
10422 void bmp_do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
10423 {
10424
10425 //sdci[1]=layer
10426 //sdci[2]=pos[12]
10427 //sdci[3]=uv[8]
10428 //sdci[4]=color[4]
10429 //sdci[5]=size[2]
10430 //sdci[6]=flip
10431 //sdci[7]=tile/combo
10432 //sdci[8]=polytype
10433 //sdci[9] = other bitmap as texture
10434 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10435 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
10436 {
10437 Z_scripterrlog("bitmap->Quad3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
10438 return;
10439 }
10440 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10441 if ( refbmp == NULL ) return;
10442
10443 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
10444
10445 if(!v_ptr)
10446 {
10447 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
10448 return;
10449 }
10450
10451 std::vector<int32_t> &v = *v_ptr;
10452
10453 if(v.empty())
10454 return;
10455
10456 int32_t* pos = &v[0];
10457 int32_t* uv = &v[12];
10458 int32_t* col = &v[20];
10459 int32_t* size = &v[24];
10460
10461 int32_t w = size[0]; //magic numerical constants... yuck.
10462 int32_t h = size[1];
10463 int32_t flip = (sdci[6]/10000)&3;
10464 int32_t tile = sdci[7]/10000;
10465 int32_t polytype = sdci[8]/10000;
10466 int32_t quad_render_source = sdci[9];
10467 Z_scripterrlog("Quad3D texture is %d\n", quad_render_source);
10468
10469 polytype = vbound(polytype, 0, 14);
10470
10471 int32_t tex_width = w*16;
10472 int32_t tex_height = h*16;
10473
10474 bool mustDestroyBmp = false;
10475 BITMAP *tex=NULL;
10476
10477
10478 bool tex_is_bitmap = ( sdci[9] != 0 );
10479 //Z_scripterrlog("sdci[9] is %d\n", quad_render_source);
10480 //Z_scripterrlog("sdci[DRAWCMD_BMP_TARGET] is %d\n", sdci[DRAWCMD_BMP_TARGET]);
10481 BITMAP *bmptexture;
10482
10483 if ( tex_is_bitmap ) bmptexture = resolveScriptingBitmap(quad_render_source);
10484
10485 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10486
10487
10488 if ( !tex_is_bitmap )
10489 {
10490 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
10491
10492 if(!tex)
10493 {
10494 mustDestroyBmp = true;
10495 tex = create_bitmap_ex(8, tex_width, tex_height);
10496 clear_bitmap(tex);
10497 }
10498 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
10499 {
10500 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
10501 return; //non power of two error
10502 }
10503 if(tile > 0) // TILE
10504 {
10505 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
10506 }
10507 else // COMBO
10508 {
10509 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
10510 const int32_t tiletodraw = combo_tile(c, 0, 0);
10511 flip = flip ^ c.flip;
10512
10513 if(!(c.animflags & AF_EDITOR_ONLY))
10514 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
10515 }
10516
10517 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10518 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10519 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10520 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
10521
10522 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
10523 if(mustDestroyBmp)
10524 destroy_bitmap(tex);
10525 }
10526 else
10527 {
10528
10529 if ( !bmptexture )
10530 {
10531 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Quad3D()");
10532 tex_is_bitmap = 0;
10533 return;
10534 }
10535 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10536 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10537 if ( !isPowerOfTwo(h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
10538 if ( !isPowerOfTwo(w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
10539
10540 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10541 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10542 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10543 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
10544
10545 BITMAP *foo = create_bitmap_ex(8, 256, 176);
10546
10547 //quad3d_f(refbmp, polytype, foo, &V1, &V2, &V3, &V4);
10548 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
10549 destroy_bitmap(foo);
10550
10551 }
10552
10553
10554
10555 }
10556
10557
10558
10559 void bmp_do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
10560 {
10561 //sdci[1]=layer
10562 //sdci[2]=pos[9]
10563 //sdci[3]=uv[6]
10564 //sdci[4]=color[3]
10565 //sdci[5]=size[2]
10566 //sdci[6]=flip
10567 //sdci[7]=tile/combo
10568 //sdci[8]=polytype
10569 //sdci[9] bitmap as texture
10570 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10571 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
10572 {
10573 Z_scripterrlog("bitmap->Triangle3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
10574 return;
10575 }
10576 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10577 if ( refbmp == NULL ) return;
10578
10579 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
10580
10581 if(!v_ptr)
10582 {
10583 al_trace("bitmap->Triangle3d: Vector pointer is null! Internal error. \n");
10584 return;
10585 }
10586
10587 std::vector<int32_t> &v = *v_ptr;
10588
10589 if(v.empty())
10590 return;
10591
10592 int32_t* pos = &v[0];
10593 int32_t* uv = &v[9];
10594 int32_t* col = &v[15];
10595 int32_t* size = &v[18];
10596
10597 int32_t w = size[0]; //magic numerical constants... yuck.
10598 int32_t h = size[1];
10599 int32_t flip = (sdci[6]/10000)&3;
10600 int32_t tile = sdci[7]/10000;
10601 int32_t polytype = sdci[8]/10000;
10602 int32_t quad_render_source = sdci[9];
10603 polytype = vbound(polytype, 0, 14);
10604
10605 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
10606 {
10607 Z_message("bitmap->Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
10608 return; //non power of two error
10609 }
10610
10611 int32_t tex_width = w*16;
10612 int32_t tex_height = h*16;
10613
10614 bool mustDestroyBmp = false;
10615 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
10616
10617 if(!tex)
10618 {
10619 mustDestroyBmp = true;
10620 tex = create_bitmap_ex(8, tex_width, tex_height);
10621 clear_bitmap(tex);
10622 }
10623
10624 bool tex_is_bitmap = ( sdci[9] != 0 );
10625 BITMAP *bmptexture=NULL;
10626 if ( tex_is_bitmap )
10627 {
10628 bmptexture = resolveScriptingBitmap(quad_render_source);
10629 if ( !bmptexture )
10630 {
10631 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
10632 tex_is_bitmap = 0;
10633 }
10634 }
10635
10636 if ( !tex_is_bitmap )
10637 {
10638 if(tile > 0) // TILE
10639 {
10640 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
10641 }
10642 else // COMBO
10643 {
10644 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
10645 const int32_t tiletodraw = combo_tile(c, 0, 0);
10646 flip = flip ^ c.flip;
10647
10648 if(!(c.animflags & AF_EDITOR_ONLY))
10649 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
10650 }
10651
10652 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10653 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10654 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10655
10656 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
10657 }
10658 else
10659 {
10660 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10661 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10662 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
10663 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
10664
10665 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10666 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10667 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10668
10669 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
10670
10671
10672 }
10673 if(mustDestroyBmp)
10674 destroy_bitmap(tex);
10675
10676 }
10677
10678
10679 bool is_layer_transparent(const mapscr& m, int32_t layer)
10680 {
10681 layer = vbound(layer, 0, 5);
10682 return m.layeropacity[layer] == 128;
10683 }
10684
10685 4513893 mapscr *getmapscreen(int32_t map_index, int32_t screen, int32_t layer) //returns NULL for invalid or non-existent layer
10686 {
10687 mapscr *base_scr;
10688 4513893 int32_t index = map_index*MAPSCRS+screen;
10689
10690
2/4
✓ Branch 0 taken 4513893 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4513893 times.
4513893 if((uint32_t)layer > 6 || (uint32_t)index >= TheMaps.size())
10691 return NULL;
10692
10693
2/2
✓ Branch 0 taken 3579197 times.
✓ Branch 1 taken 934696 times.
4513893 if(layer != 0)
10694 {
10695 934696 layer = layer - 1;
10696
10697 934696 base_scr=&(TheMaps[index]);
10698
10699
2/2
✓ Branch 0 taken 842046 times.
✓ Branch 1 taken 92650 times.
934696 if(base_scr->layermap[layer]==0)
10700 92650 return NULL;
10701
10702 842046 index=(base_scr->layermap[layer]-1)*MAPSCRS+base_scr->layerscreen[layer];
10703
10704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 842046 times.
842046 if((uint32_t)index >= TheMaps.size()) // Might as well make sure
10705 return NULL;
10706 842046 }
10707
10708 4421243 return &(TheMaps[index]);
10709 4513893 }
10710
10711 659237800 static bool transparent_combo(int32_t id)
10712 {
10713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 659237800 times.
659237800 if(unsigned(id) >= MAXCOMBOS) return false;
10714 659237800 return bool(combobuf[id].animflags & AF_TRANSPARENT);
10715 659237800 }
10716
10717 199800 void draw_mapscr(BITMAP *b, const mapscr& m, int32_t x, int32_t y, bool transparent)
10718 {
10719
2/2
✓ Branch 0 taken 35164800 times.
✓ Branch 1 taken 199800 times.
35364600 for(int32_t i(0); i < 176; ++i)
10720 {
10721 35164800 const int32_t x2 = ((i&15)<<4) + x;
10722 35164800 const int32_t y2 = (i&0xF0) + y;
10723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35164800 times.
35164800 if(combobuf[m.data[i]].animflags & AF_EDITOR_ONLY) continue;
10724
10725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35164800 times.
35164800 if(transparent != transparent_combo(m.data[i]))
10726 {
10727 overcomboblocktranslucent(b, x2, y2, m.data[i], m.cset[i], 1, 1, 128);
10728 }
10729 else
10730 {
10731 35164800 overcomboblock(b, x2, y2, m.data[i], m.cset[i], 1, 1);
10732 }
10733 35164800 }
10734 199800 }
10735
10736 void draw_map_solidity(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10737 {
10738 BITMAP* square = create_bitmap_ex(8,16,16);
10739
10740 for(int32_t i(0); i < 176; ++i)
10741 {
10742 const int32_t x2 = ((i&15)<<4) + x;
10743 const int32_t y2 = (i&0xF0) + y;
10744 //Blit the palette index of the solidity value.
10745 clear_to_color(square,(combobuf[m.data[i]].walk&15));
10746 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10747 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10748 }
10749 destroy_bitmap(square);
10750 }
10751
10752 void do_bmpdrawscreen_solidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10753 {
10754 //sdci[1]=layer
10755 //sdci[2]=map
10756 //sdci[3]=screen
10757 //sdci[4]=x
10758 //sdci[5]=y
10759 //sdci[6]=rotation
10760 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10761
10762 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10763 if ( refbmp == NULL ) return;
10764
10765 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10766
10767 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10768 int32_t screen = sdci[3]/10000;
10769 int32_t x = sdci[4]/10000;
10770 int32_t y = sdci[5]/10000;
10771 int32_t x1 = x + xoffset;
10772 int32_t y1 = y + yoffset;
10773 int32_t rotation = sdci[6]/10000;
10774 uint32_t index = (uint32_t)map_screen_index(map, screen);
10775
10776 if(index >= TheMaps.size())
10777 {
10778 al_trace("DrawScreen: invalid map or screen index. \n");
10779 return;
10780 }
10781
10782 const mapscr & m = TheMaps[index];
10783
10784
10785 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10786 if ( refbmp == NULL ) return;
10787
10788 if(rotation != 0)
10789 b = script_drawing_commands.AquireSubBitmap(256, 176);
10790
10791 //draw layer 0
10792 draw_map_solidity(b, m, x1, y1);
10793 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
10794 {
10795 for(int32_t i(0); i < 6; ++i)
10796 {
10797 if(m.layermap[i] == 0) continue;
10798
10799 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10800
10801 if(layer_screen_index >= TheMaps.size())
10802 continue;
10803
10804 //draw valid layers
10805 draw_map_solidity(b, TheMaps[ layer_screen_index ], x1, y1);
10806 }
10807 }
10808
10809 if(rotation != 0) // rotate
10810 {
10811 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10812 script_drawing_commands.ReleaseSubBitmap(b);
10813 }
10814 }
10815
10816 void draw_map_solid(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10817 {
10818 BITMAP* square = create_bitmap_ex(8,16,16);
10819 BITMAP* subsquare = create_bitmap_ex(8,16,16);
10820 clear_to_color(subsquare,1);
10821
10822 for(int32_t i(0); i < 176; ++i)
10823 {
10824 const int32_t x2 = ((i&15)<<4) + x;
10825 const int32_t y2 = (i&0xF0) + y;
10826 //Blit the palette index of the solidity value.
10827 clear_bitmap(square);
10828 int32_t sol = (combobuf[m.data[i]].walk);
10829 if ( sol & 1 )
10830 {
10831 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
10832 }
10833 if ( sol & 2 )
10834 {
10835 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
10836 }
10837 if ( sol & 4 )
10838 {
10839 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
10840 }
10841 if ( sol &8 ) {
10842 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
10843 }
10844
10845 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10846 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10847 }
10848 destroy_bitmap(square);
10849 destroy_bitmap(subsquare);
10850 }
10851
10852 void do_bmpdrawscreen_solidr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10853 {
10854 //sdci[1]=layer
10855 //sdci[2]=map
10856 //sdci[3]=screen
10857 //sdci[4]=x
10858 //sdci[5]=y
10859 //sdci[6]=rotation
10860 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10861
10862 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10863 if ( refbmp == NULL ) return;
10864
10865 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10866
10867 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10868 int32_t screen = sdci[3]/10000;
10869 int32_t x = sdci[4]/10000;
10870 int32_t y = sdci[5]/10000;
10871 int32_t x1 = x + xoffset;
10872 int32_t y1 = y + yoffset;
10873 int32_t rotation = sdci[6]/10000;
10874
10875 uint32_t index = (uint32_t)map_screen_index(map, screen);
10876
10877 if(index >= TheMaps.size())
10878 {
10879 al_trace("DrawScreen: invalid map or screen index. \n");
10880 return;
10881 }
10882
10883 const mapscr & m = TheMaps[index];
10884
10885
10886 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10887 if ( refbmp == NULL ) return;
10888
10889 if(rotation != 0)
10890 b = script_drawing_commands.AquireSubBitmap(256, 176);
10891
10892 //draw layer 0
10893 draw_map_solid(b, m, x1, y1);
10894
10895 for(int32_t i(0); i < 6; ++i) //This one doesn't need the QR; it works just fine.
10896 {
10897 if(m.layermap[i] == 0) continue;
10898
10899 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10900
10901 if(layer_screen_index >= TheMaps.size())
10902 continue;
10903
10904 //draw valid layers
10905 draw_map_solid(b, TheMaps[ layer_screen_index ], x1, y1);
10906 }
10907
10908 if(rotation != 0) // rotate
10909 {
10910 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10911 script_drawing_commands.ReleaseSubBitmap(b);
10912 }
10913 }
10914
10915 1024 void draw_map_cflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10916 {
10917 1024 BITMAP* square = create_bitmap_ex(8,16,16);
10918
10919
2/2
✓ Branch 0 taken 180224 times.
✓ Branch 1 taken 1024 times.
181248 for(int32_t i(0); i < 176; ++i)
10920 {
10921 180224 const int32_t x2 = ((i&15)<<4) + x;
10922 180224 const int32_t y2 = (i&0xF0) + y;
10923 //Blit the palette index of the solidity value.
10924 180224 clear_to_color(square,m.sflag[i]);
10925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180224 times.
180224 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10926 180224 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10927 180224 }
10928 1024 destroy_bitmap(square);
10929 1024 }
10930
10931 1024 void do_bmpdrawscreen_cflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10932 {
10933 //sdci[1]=layer
10934 //sdci[2]=map
10935 //sdci[3]=screen
10936 //sdci[4]=x
10937 //sdci[5]=y
10938 //sdci[6]=rotation
10939 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10940
10941 1024 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10942
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( refbmp == NULL ) return;
10943
10944
2/4
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
1024 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10945
10946 1024 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10947 1024 int32_t screen = sdci[3]/10000;
10948 1024 int32_t x = sdci[4]/10000;
10949 1024 int32_t y = sdci[5]/10000;
10950 1024 int32_t x1 = x + xoffset;
10951 1024 int32_t y1 = y + yoffset;
10952 1024 int32_t rotation = sdci[6]/10000;
10953
10954 1024 uint32_t index = (uint32_t)map_screen_index(map, screen);
10955
10956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(index >= TheMaps.size())
10957 {
10958 al_trace("DrawScreen: invalid map or screen index. \n");
10959 return;
10960 }
10961
10962 1024 const mapscr & m = TheMaps[index];
10963
10964
10965 1024 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10966
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( refbmp == NULL ) return;
10967
10968
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0)
10969 b = script_drawing_commands.AquireSubBitmap(256, 176);
10970
10971 //draw layer 0
10972 1024 draw_map_cflag(b, m, x1, y1);
10973
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
10974 {
10975 for(int32_t i(0); i < 6; ++i)
10976 {
10977 if(m.layermap[i] == 0) continue;
10978
10979 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10980
10981 if(layer_screen_index >= TheMaps.size())
10982 continue;
10983
10984 //draw valid layers
10985 draw_map_cflag(b, TheMaps[ layer_screen_index ], x1, y1);
10986 }
10987 }
10988
10989
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0) // rotate
10990 {
10991 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10992 script_drawing_commands.ReleaseSubBitmap(b);
10993 }
10994 1024 }
10995
10996
10997 void draw_map_combotype(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10998 {
10999 BITMAP* square = create_bitmap_ex(8,16,16);
11000
11001 for(int32_t i(0); i < 176; ++i)
11002 {
11003 const int32_t x2 = ((i&15)<<4) + x;
11004 const int32_t y2 = (i&0xF0) + y;
11005 //Blit the palette index of the solidity value.
11006 clear_to_color(square,(combobuf[m.data[i]].type));
11007 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
11008 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
11009 }
11010 destroy_bitmap(square);
11011 }
11012
11013 void do_bmpdrawscreen_ctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11014 {
11015 //sdci[1]=layer
11016 //sdci[2]=map
11017 //sdci[3]=screen
11018 //sdci[4]=x
11019 //sdci[5]=y
11020 //sdci[6]=rotation
11021 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11022
11023 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11024 if ( refbmp == NULL ) return;
11025
11026 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11027
11028 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11029 int32_t screen = sdci[3]/10000;
11030 int32_t x = sdci[4]/10000;
11031 int32_t y = sdci[5]/10000;
11032 int32_t x1 = x + xoffset;
11033 int32_t y1 = y + yoffset;
11034 int32_t rotation = sdci[6]/10000;
11035
11036 uint32_t index = (uint32_t)map_screen_index(map, screen);
11037
11038 if(index >= TheMaps.size())
11039 {
11040 al_trace("DrawScreen: invalid map or screen index. \n");
11041 return;
11042 }
11043
11044 const mapscr & m = TheMaps[index];
11045
11046
11047 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11048 if ( refbmp == NULL ) return;
11049
11050 if(rotation != 0)
11051 b = script_drawing_commands.AquireSubBitmap(256, 176);
11052
11053 //draw layer 0
11054 draw_map_combotype(b, m, x1, y1);
11055
11056 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
11057 {
11058 for(int32_t i(0); i < 6; ++i)
11059 {
11060 if(m.layermap[i] == 0) continue;
11061
11062 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11063
11064 if(layer_screen_index >= TheMaps.size())
11065 continue;
11066
11067 //draw valid layers
11068 draw_map_combotype(b, TheMaps[ layer_screen_index ], x1, y1);
11069 }
11070 }
11071
11072 if(rotation != 0) // rotate
11073 {
11074 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11075 script_drawing_commands.ReleaseSubBitmap(b);
11076 }
11077 }
11078
11079
11080 void draw_map_comboiflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
11081 {
11082 BITMAP* square = create_bitmap_ex(8,16,16);
11083
11084 for(int32_t i(0); i < 176; ++i)
11085 {
11086 const int32_t x2 = ((i&15)<<4) + x;
11087 const int32_t y2 = (i&0xF0) + y;
11088 //Blit the palette index of the solidity value.
11089 clear_to_color(square,(combobuf[m.data[i]].flag));
11090 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
11091 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
11092 }
11093 destroy_bitmap(square);
11094 }
11095
11096 void do_bmpdrawscreen_ciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11097 {
11098 //sdci[1]=layer
11099 //sdci[2]=map
11100 //sdci[3]=screen
11101 //sdci[4]=x
11102 //sdci[5]=y
11103 //sdci[6]=rotation
11104 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11105
11106 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11107 if ( refbmp == NULL ) return;
11108
11109 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11110
11111 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11112 int32_t screen = sdci[3]/10000;
11113 int32_t x = sdci[4]/10000;
11114 int32_t y = sdci[5]/10000;
11115 int32_t x1 = x + xoffset;
11116 int32_t y1 = y + yoffset;
11117 int32_t rotation = sdci[6]/10000;
11118
11119 uint32_t index = (uint32_t)map_screen_index(map, screen);
11120
11121 if(index >= TheMaps.size())
11122 {
11123 al_trace("DrawScreen: invalid map or screen index. \n");
11124 return;
11125 }
11126
11127 const mapscr & m = TheMaps[index];
11128
11129
11130 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11131 if ( refbmp == NULL ) return;
11132
11133 if(rotation != 0)
11134 b = script_drawing_commands.AquireSubBitmap(256, 176);
11135
11136 //draw layer 0
11137 draw_map_comboiflag(b, m, x1, y1);
11138
11139 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
11140 {
11141 for(int32_t i(0); i < 6; ++i)
11142 {
11143 if(m.layermap[i] == 0) continue;
11144
11145 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11146
11147 if(layer_screen_index >= TheMaps.size())
11148 continue;
11149
11150 //draw valid layers
11151 draw_map_comboiflag(b, TheMaps[ layer_screen_index ], x1, y1);
11152 }
11153 }
11154
11155 if(rotation != 0) // rotate
11156 {
11157 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11158 script_drawing_commands.ReleaseSubBitmap(b);
11159 }
11160 }
11161
11162 4370235 void do_drawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11163 {
11164 //sdci[1]=layer
11165 //sdci[2]=map
11166 //sdci[3]=screen
11167 //sdci[4]=layer
11168 //sdci[5]=x
11169 //sdci[6]=y
11170 //sdci[7]=rotation
11171 //sdci[8]=opacity
11172
11173 4370235 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11174 4370235 int32_t screen = sdci[3]/10000;
11175 4370235 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11176 4370235 int32_t x = sdci[5]/10000;
11177 4370235 int32_t y = sdci[6]/10000;
11178 4370235 int32_t x1 = x + xoffset;
11179 4370235 int32_t y1 = y + yoffset;
11180 4370235 int32_t rotation = sdci[7]/10000;
11181 4370235 int32_t opacity = sdci[8]/10000;
11182
11183 4370235 uint32_t index = (uint32_t)map_screen_index(map, screen);
11184 4370235 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11185
11186
2/2
✓ Branch 0 taken 4318301 times.
✓ Branch 1 taken 51934 times.
4370235 if(!m) //no need to log it.
11187 51934 return;
11188
11189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4318301 times.
4318301 if(index >= TheMaps.size())
11190 {
11191 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11192 return;
11193 }
11194
11195 4318301 const mapscr & l = *m;
11196
11197 4318301 BITMAP* b = bmp;
11198
11199
1/2
✓ Branch 0 taken 4318301 times.
✗ Branch 1 not taken.
4318301 if(rotation != 0)
11200 b = script_drawing_commands.AquireSubBitmap(256, 176);
11201
11202
11203 4318301 const int32_t maxX = isOffScreen ? 512 : 256;
11204
2/2
✓ Branch 0 taken 4298918 times.
✓ Branch 1 taken 19383 times.
4318301 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11205 4318301 bool transparent = opacity <= 128;
11206
11207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4318301 times.
4318301 if(rotation != 0) // rotate
11208 {
11209 draw_mapscr(b, l, x1, y1, transparent);
11210
11211 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11212 script_drawing_commands.ReleaseSubBitmap(b);
11213 }
11214 else
11215 {
11216
2/2
✓ Branch 0 taken 760020976 times.
✓ Branch 1 taken 4318301 times.
764339277 for(int32_t i(0); i < 176; ++i)
11217 {
11218 760020976 const int32_t x2 = ((i&15)<<4) + x1;
11219 760020976 const int32_t y2 = (i&0xF0) + y1;
11220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760020976 times.
760020976 if(combobuf[l.data[i]].animflags & AF_EDITOR_ONLY) continue;
11221
11222
7/8
✓ Branch 0 taken 669516342 times.
✓ Branch 1 taken 90504634 times.
✓ Branch 2 taken 669516342 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 615110950 times.
✓ Branch 5 taken 54405392 times.
✓ Branch 6 taken 9155742 times.
✓ Branch 7 taken 605955208 times.
760020976 if(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY) //in clipping rect
11223 {
11224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 605955208 times.
605955208 if(opacity < 128 != transparent_combo(l.data[i]))
11225 {
11226 overcomboblocktranslucent(b, x2, y2, l.data[i], l.cset[i], 1, 1, 128);
11227 }
11228 else
11229 {
11230 605955208 overcomboblock(b, x2, y2, l.data[i], l.cset[i], 1, 1);
11231 }
11232 605955208 }
11233 760020976 }
11234 }
11235
11236 //putscr
11237 4370235 }
11238
11239
11240
11241 50406 void do_drawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11242 {
11243 //sdci[1]=layer
11244 //sdci[2]=map
11245 //sdci[3]=screen
11246 //sdci[4]=x
11247 //sdci[5]=y
11248 //sdci[6]=rotation
11249
11250 50406 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11251 50406 int32_t screen = sdci[3]/10000;
11252 50406 int32_t x = sdci[4]/10000;
11253 50406 int32_t y = sdci[5]/10000;
11254 50406 int32_t x1 = x + xoffset;
11255 50406 int32_t y1 = y + yoffset;
11256 50406 int32_t rotation = sdci[6]/10000;
11257
11258 50406 uint32_t index = (uint32_t)map_screen_index(map, screen);
11259
11260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(index >= TheMaps.size())
11261 {
11262 al_trace("DrawScreen: invalid map or screen index. \n");
11263 return;
11264 }
11265
11266 50406 const mapscr & m = TheMaps[index];
11267
11268
11269 50406 BITMAP* b = bmp;
11270
11271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(rotation != 0)
11272 b = script_drawing_commands.AquireSubBitmap(256, 176);
11273
11274 //draw layer 0
11275 50406 draw_mapscr(b, m, x1, y1, false);
11276
11277
2/2
✓ Branch 0 taken 50406 times.
✓ Branch 1 taken 302436 times.
352842 for(int32_t i(0); i < 6; ++i)
11278 {
11279
2/2
✓ Branch 0 taken 137944 times.
✓ Branch 1 taken 164492 times.
302436 if(m.layermap[i] == 0) continue;
11280
11281 137944 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11282
11283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137944 times.
137944 if(layer_screen_index >= TheMaps.size())
11284 continue;
11285
11286 137944 bool trans = m.layeropacity[i] == 128;
11287
11288 //draw valid layers
11289 137944 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
11290 137944 }
11291
11292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(rotation != 0) // rotate
11293 {
11294 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11295 script_drawing_commands.ReleaseSubBitmap(b);
11296 }
11297 50406 }
11298
11299
11300 143658 void do_bmpdrawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11301 {
11302 //sdci[1]=layer
11303 //sdci[2]=map
11304 //sdci[3]=screen
11305 //sdci[4]=layer
11306 //sdci[5]=x
11307 //sdci[6]=y
11308 //sdci[7]=rotation
11309 //[8] noclip
11310 //sdci[9]=opacity
11311 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11312
11313 143658 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11314
1/2
✓ Branch 0 taken 143658 times.
✗ Branch 1 not taken.
143658 if ( refbmp == NULL ) return;
11315
11316 143658 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11317 143658 int32_t screen = sdci[3]/10000;
11318 143658 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11319 143658 int32_t x = sdci[5]/10000;
11320 143658 int32_t y = sdci[6]/10000;
11321 143658 int32_t rotation = sdci[7]/10000;
11322
11323 143658 byte noclip = 0;//(sdci[8]!=0);
11324 143658 int32_t opacity = sdci[8]/10000;
11325 143658 uint32_t index = (uint32_t)map_screen_index(map, screen);
11326 143658 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11327
11328
2/2
✓ Branch 0 taken 102942 times.
✓ Branch 1 taken 40716 times.
143658 if(!m) //no need to log it.
11329 40716 return;
11330
11331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 if(index >= TheMaps.size())
11332 {
11333 Z_scripterrlog("DrawLayer: invalid map index \"%i\". Map count is %zu.\n", index, TheMaps.size());
11334 return;
11335 }
11336
11337 102942 const mapscr & l = *m;
11338
11339 102942 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11340
1/2
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
102942 if ( refbmp == NULL ) return;
11341
2/4
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102942 times.
✗ Branch 3 not taken.
102942 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11342
1/2
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
102942 if(rotation != 0)
11343 b = script_drawing_commands.AquireSubBitmap(256, 176);
11344
11345
11346 102942 const int32_t maxX = isOffScreen ? 512 : 256;
11347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11348 102942 bool transparent = opacity <= 128;
11349
11350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 if(rotation != 0) // rotate
11351 {
11352 draw_mapscr(b, l, x, y, transparent);
11353
11354 rotate_sprite(refbmp, b, x, y, degrees_to_fixed(rotation));
11355 script_drawing_commands.ReleaseSubBitmap(b);
11356 }
11357 else
11358 {
11359
2/2
✓ Branch 0 taken 18117792 times.
✓ Branch 1 taken 102942 times.
18220734 for(int32_t i(0); i < 176; ++i)
11360 {
11361 18117792 const int32_t x2 = ((i&15)<<4) + x;
11362 18117792 const int32_t y2 = (i&0xF0) + y;
11363
11364 //if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11365 {
11366 18117792 auto& c = GET_DRAWING_COMBO(l.data[i]);
11367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18117792 times.
18117792 if(c.animflags & AF_EDITOR_ONLY) continue;
11368 18117792 const int32_t tile = combo_tile(c, x2, y2);
11369
11370
2/2
✓ Branch 0 taken 37572 times.
✓ Branch 1 taken 18080220 times.
18117792 if(opacity < 128 != transparent_combo(l.data[i]))
11371 37572 overtiletranslucent16(refbmp, tile, x2, y2, l.cset[i], c.flip, opacity);
11372 else
11373 18080220 overtile16(refbmp, tile, x2, y2, l.cset[i], c.flip);
11374
11375 //putcombo( b, xx, yy, l.data[i], l.cset[i] );
11376 }
11377 18117792 }
11378 }
11379
11380 //putscr
11381 143658 }
11382
11383
11384
11385 2740 void do_bmpdrawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11386 {
11387 //sdci[1]=layer
11388 //sdci[2]=map
11389 //sdci[3]=screen
11390 //sdci[4]=x
11391 //sdci[5]=y
11392 //sdci[6]=rotation
11393 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11394
11395 2740 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11396
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if ( refbmp == NULL ) return;
11397
11398
2/4
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2740 times.
2740 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11399
11400 2740 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11401 2740 int32_t screen = sdci[3]/10000;
11402 2740 int32_t x = sdci[4]/10000;
11403 2740 int32_t y = sdci[5]/10000;
11404 2740 int32_t x1 = x + xoffset;
11405 2740 int32_t y1 = y + yoffset;
11406 2740 int32_t rotation = sdci[6]/10000;
11407
11408 2740 uint32_t index = (uint32_t)map_screen_index(map, screen);
11409
11410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2740 times.
2740 if(index >= TheMaps.size())
11411 {
11412 al_trace("DrawScreen: invalid map or screen index. \n");
11413 return;
11414 }
11415
11416 2740 const mapscr & m = TheMaps[index];
11417
11418
11419 2740 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2740 times.
2740 if ( refbmp == NULL ) return;
11421
11422
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if(rotation != 0)
11423 b = script_drawing_commands.AquireSubBitmap(256, 176);
11424
11425 //draw layer 0
11426 2740 draw_mapscr(b, m, x1, y1, false);
11427
11428
2/2
✓ Branch 0 taken 2740 times.
✓ Branch 1 taken 16440 times.
19180 for(int32_t i(0); i < 6; ++i)
11429 {
11430
2/2
✓ Branch 0 taken 8710 times.
✓ Branch 1 taken 7730 times.
16440 if(m.layermap[i] == 0) continue;
11431
11432 8710 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11433
11434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8710 times.
8710 if(layer_screen_index >= TheMaps.size())
11435 continue;
11436
11437 8710 bool trans = m.layeropacity[i] == 128;
11438
11439 //draw valid layers
11440 8710 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
11441 8710 }
11442
11443
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if(rotation != 0) // rotate
11444 {
11445 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11446 script_drawing_commands.ReleaseSubBitmap(b);
11447 }
11448 2740 }
11449
11450 void do_bmpdrawlayersolidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11451 {
11452 //sdci[1]=layer
11453 //sdci[2]=map
11454 //sdci[3]=screen
11455 //sdci[4]=layer
11456 //sdci[5]=x
11457 //sdci[6]=y
11458 //sdci[7]=rotation
11459 //sdci[8]=bool noclip
11460 //sdci[9] == opacity
11461
11462 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11463 int32_t screen = sdci[3]/10000;
11464 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11465 int32_t x = sdci[5]/10000;
11466 int32_t y = sdci[6]/10000;
11467 int32_t x1 = x + xoffset;
11468 int32_t y1 = y + yoffset;
11469 int32_t rotation = sdci[7]/10000;
11470 byte noclip = (sdci[8]!=0);
11471 int32_t opacity = sdci[9]/10000;
11472
11473 uint32_t index = (uint32_t)map_screen_index(map, screen);
11474 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11475
11476 if(!m) //no need to log it.
11477 return;
11478
11479 if(index >= TheMaps.size())
11480 {
11481 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11482 return;
11483 }
11484
11485 const mapscr & l = *m;
11486
11487 BITMAP* b = bmp;
11488
11489 if(rotation != 0)
11490 b = script_drawing_commands.AquireSubBitmap(256, 176);
11491
11492
11493 const int32_t maxX = isOffScreen ? 512 : 256;
11494 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11495 bool transparent = opacity <= 128;
11496
11497 if(rotation != 0) // rotate
11498 {
11499 draw_map_solid(b, l, x1, y1);
11500
11501 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11502 script_drawing_commands.ReleaseSubBitmap(b);
11503 }
11504 else
11505 {
11506 BITMAP* square = create_bitmap_ex(8,16,16);
11507 BITMAP* subsquare = create_bitmap_ex(8,16,16);
11508 clear_to_color(subsquare,1);
11509 for(int32_t i(0); i < 176; ++i)
11510 {
11511 const int32_t x2 = ((i&15)<<4) + x1;
11512 const int32_t y2 = (i&0xF0) + y1;
11513
11514 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11515 {
11516 int32_t sol = (combobuf[l.data[i]].walk);
11517
11518 if ( sol & 1 )
11519 {
11520 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
11521 }
11522 if ( sol & 2 )
11523 {
11524 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
11525 }
11526 if ( sol & 4 )
11527 {
11528 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
11529 }
11530 if ( sol &8 ) {
11531 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
11532 }
11533
11534 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11535 }
11536 }
11537 destroy_bitmap(square);
11538 destroy_bitmap(subsquare);
11539 }
11540
11541 //putscr
11542 }
11543
11544 void do_bmpdrawlayersolidityr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11545 {
11546 //sdci[1]=layer
11547 //sdci[2]=map
11548 //sdci[3]=screen
11549 //sdci[4]=layer
11550 //sdci[5]=x
11551 //sdci[6]=y
11552 //sdci[7]=rotation
11553 //[8] noclip
11554 //sdci[9]=opacity
11555
11556
11557 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11558 int32_t screen = sdci[3]/10000;
11559 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11560 int32_t x = sdci[5]/10000;
11561 int32_t y = sdci[6]/10000;
11562 int32_t x1 = x + xoffset;
11563 int32_t y1 = y + yoffset;
11564 int32_t rotation = sdci[7]/10000;
11565 byte noclip = (sdci[8]!=0);
11566 int32_t opacity = sdci[9]/10000;
11567
11568 uint32_t index = (uint32_t)map_screen_index(map, screen);
11569 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11570
11571 if(!m) //no need to log it.
11572 return;
11573
11574 if(index >= TheMaps.size())
11575 {
11576 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11577 return;
11578 }
11579
11580 const mapscr & l = *m;
11581
11582 BITMAP* b = bmp;
11583
11584 if(rotation != 0)
11585 b = script_drawing_commands.AquireSubBitmap(256, 176);
11586
11587
11588 const int32_t maxX = isOffScreen ? 512 : 256;
11589 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11590 bool transparent = opacity <= 128;
11591
11592 if(rotation != 0) // rotate
11593 {
11594 draw_map_solidity(b, l, x1, y1);
11595
11596 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11597 script_drawing_commands.ReleaseSubBitmap(b);
11598 }
11599 else
11600 {
11601 BITMAP* square = create_bitmap_ex(8,16,16);
11602 for(int32_t i(0); i < 176; ++i)
11603 {
11604 const int32_t x2 = ((i&15)<<4) + x1;
11605 const int32_t y2 = (i&0xF0) + y1;
11606
11607 if(noclip && (x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11608 {
11609 clear_to_color(square,(combobuf[l.data[i]].walk&15));
11610 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11611 }
11612 }
11613 destroy_bitmap(square);
11614 }
11615
11616 //putscr
11617 }
11618
11619 void do_bmpdrawlayercflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11620 {
11621 //sdci[1]=layer
11622 //sdci[2]=map
11623 //sdci[3]=screen
11624 //sdci[4]=layer
11625 //sdci[5]=x
11626 //sdci[6]=y
11627 //sdci[7]=rotation
11628 //[8] noclip
11629 //sdci[9]=opacity
11630
11631
11632 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11633 int32_t screen = sdci[3]/10000;
11634 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11635 int32_t x = sdci[5]/10000;
11636 int32_t y = sdci[6]/10000;
11637 int32_t x1 = x + xoffset;
11638 int32_t y1 = y + yoffset;
11639 int32_t rotation = sdci[7]/10000;
11640
11641 byte noclip = (sdci[8]!=0);
11642 int32_t opacity = sdci[9]/10000;
11643
11644 uint32_t index = (uint32_t)map_screen_index(map, screen);
11645 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11646
11647 if(!m) //no need to log it.
11648 return;
11649
11650 if(index >= TheMaps.size())
11651 {
11652 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11653 return;
11654 }
11655
11656 const mapscr & l = *m;
11657
11658 BITMAP* b = bmp;
11659
11660 if(rotation != 0)
11661 b = script_drawing_commands.AquireSubBitmap(256, 176);
11662
11663
11664 const int32_t maxX = isOffScreen ? 512 : 256;
11665 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11666 bool transparent = opacity <= 128;
11667
11668 if(rotation != 0) // rotate
11669 {
11670 draw_map_cflag(b, l, x1, y1);
11671
11672 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11673 script_drawing_commands.ReleaseSubBitmap(b);
11674 }
11675 else
11676 {
11677 BITMAP* square = create_bitmap_ex(8,16,16);
11678 for(int32_t i(0); i < 176; ++i)
11679 {
11680 const int32_t x2 = ((i&15)<<4) + x1;
11681 const int32_t y2 = (i&0xF0) + y1;
11682
11683 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11684 {
11685 clear_to_color(square,l.sflag[i]);
11686 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11687 }
11688 }
11689 destroy_bitmap(square);
11690 }
11691
11692 //putscr
11693 }
11694
11695 void do_bmpdrawlayerctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11696 {
11697 //sdci[1]=layer
11698 //sdci[2]=map
11699 //sdci[3]=screen
11700 //sdci[4]=layer
11701 //sdci[5]=x
11702 //sdci[6]=y
11703 //sdci[7]=rotation
11704 //[8] noclip
11705 //sdci[9]=opacity
11706
11707 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11708 int32_t screen = sdci[3]/10000;
11709 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11710 int32_t x = sdci[5]/10000;
11711 int32_t y = sdci[6]/10000;
11712 int32_t x1 = x + xoffset;
11713 int32_t y1 = y + yoffset;
11714 int32_t rotation = sdci[7]/10000;
11715
11716 byte noclip = (sdci[8]!=0);
11717 int32_t opacity = sdci[9]/10000;
11718 uint32_t index = (uint32_t)map_screen_index(map, screen);
11719 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11720
11721 if(!m) //no need to log it.
11722 return;
11723
11724 if(index >= TheMaps.size())
11725 {
11726 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11727 return;
11728 }
11729
11730 const mapscr & l = *m;
11731
11732 BITMAP* b = bmp;
11733
11734 if(rotation != 0)
11735 b = script_drawing_commands.AquireSubBitmap(256, 176);
11736
11737
11738 const int32_t maxX = isOffScreen ? 512 : 256;
11739 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11740 bool transparent = opacity <= 128;
11741
11742 if(rotation != 0) // rotate
11743 {
11744 draw_map_combotype(b, l, x1, y1);
11745
11746 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11747 script_drawing_commands.ReleaseSubBitmap(b);
11748 }
11749 else
11750 {
11751 BITMAP* square = create_bitmap_ex(8,16,16);
11752 for(int32_t i(0); i < 176; ++i)
11753 {
11754 const int32_t x2 = ((i&15)<<4) + x1;
11755 const int32_t y2 = (i&0xF0) + y1;
11756
11757 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11758 {
11759 clear_to_color(square,(combobuf[l.data[i]].type));
11760 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11761 }
11762 }
11763 destroy_bitmap(square);
11764 }
11765
11766 //putscr
11767 }
11768
11769 void do_bmpdrawlayerciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11770 {
11771 //sdci[1]=layer
11772 //sdci[2]=map
11773 //sdci[3]=screen
11774 //sdci[4]=layer
11775 //sdci[5]=x
11776 //sdci[6]=y
11777 //sdci[7]=rotation
11778 //[8] noclip
11779 //sdci[9]=opacity
11780
11781 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11782 int32_t screen = sdci[3]/10000;
11783 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11784 int32_t x = sdci[5]/10000;
11785 int32_t y = sdci[6]/10000;
11786 int32_t x1 = x + xoffset;
11787 int32_t y1 = y + yoffset;
11788 int32_t rotation = sdci[7]/10000;
11789 byte noclip = (sdci[8]!=0);
11790 int32_t opacity = sdci[9]/10000;
11791
11792 uint32_t index = (uint32_t)map_screen_index(map, screen);
11793 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11794
11795 if(!m) //no need to log it.
11796 return;
11797
11798 if(index >= TheMaps.size())
11799 {
11800 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11801 return;
11802 }
11803
11804 const mapscr & l = *m;
11805
11806 BITMAP* b = bmp;
11807
11808 if(rotation != 0)
11809 b = script_drawing_commands.AquireSubBitmap(256, 176);
11810
11811
11812 const int32_t maxX = isOffScreen ? 512 : 256;
11813 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11814 bool transparent = opacity <= 128;
11815
11816 if(rotation != 0) // rotate
11817 {
11818 draw_map_comboiflag(b, l, x1, y1);
11819
11820 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11821 script_drawing_commands.ReleaseSubBitmap(b);
11822 }
11823 else
11824 {
11825 BITMAP* square = create_bitmap_ex(8,16,16);
11826 for(int32_t i(0); i < 176; ++i)
11827 {
11828 const int32_t x2 = ((i&15)<<4) + x1;
11829 const int32_t y2 = (i&0xF0) + y1;
11830
11831 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11832 {
11833 clear_to_color(square,(combobuf[l.data[i]].flag));
11834 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11835 }
11836 }
11837 destroy_bitmap(square);
11838 }
11839
11840 //putscr
11841 }
11842
11843
11844
11845 /////////////////////////////////////////////////////////
11846 // do primitives
11847 ////////////////////////////////////////////////////////
11848
11849 // Draw commands can vary in terms of the origin/coordinate system to draw as. This
11850 // is controlled via `DrawOrigin`. Previous to `DrawOrigin`, this always drew
11851 // relative to the playing field (except for offscreen bitmaps).
11852 417362412 void do_primitives(BITMAP *targetBitmap, int32_t type)
11853 {
11854 417362412 do_primitives(targetBitmap, type, 0, playing_field_offset);
11855 417362412 }
11856
11857 418724884 void do_primitives(BITMAP *targetBitmap, int32_t type, int32_t xoff, int32_t yoff)
11858 {
11859 418724884 color_map = &trans_table2;
11860
11861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418724884 times.
418724884 if(type > 7)
11862 return;
11863
3/4
✓ Branch 0 taken 133703448 times.
✓ Branch 1 taken 285021436 times.
✓ Branch 2 taken 133703448 times.
✗ Branch 3 not taken.
418724884 if(type >= 0 && origin_scr->hidescriptlayers & (1<<type))
11864 return; //Script draws hidden for this layer
11865
2/2
✓ Branch 0 taken 4855801 times.
✓ Branch 1 taken 413869083 times.
418724884 if(!script_drawing_commands.is_dirty(type))
11866 413869083 return; //No draws to this layer
11867 //--script_drawing_commands[][] reference--
11868 //[][0]: type
11869 //[][1-16]: defined by type
11870 //...
11871 //[][DRAWCMD_BMP_TARGET]: bitmap pointer
11872 //[][DRAWCMD_CURRENT_TARGET]: current render target at time command is queued? unused?
11873
11874 4855801 const int32_t type_mul_10000 = type * 10000;
11875 4855801 const int32_t numDrawCommandsToProcess = script_drawing_commands.Count();
11876 4855801 FFCore.numscriptdraws = numDrawCommandsToProcess;
11877
11878
2/2
✓ Branch 0 taken 369784523 times.
✓ Branch 1 taken 4855801 times.
374640324 for (int i = 0; i < numDrawCommandsToProcess; i++)
11879 {
11880 369784523 auto& command = script_drawing_commands[i];
11881 369784523 int32_t *sdci = &script_drawing_commands[i][0];
11882
11883
2/2
✓ Branch 0 taken 246614115 times.
✓ Branch 1 taken 123170408 times.
369784523 if (sdci[1] != type_mul_10000)
11884 246614115 continue;
11885
11886 123170408 DrawOrigin draw_origin = command.draw_origin;
11887
11888 // get the correct render target, if set via Screen->SetRenderTarget
11889 // Note: This is a deprecated feature.
11890 123170408 BITMAP *bmp = zscriptDrawingRenderTarget->GetTargetBitmap(sdci[DRAWCMD_CURRENT_TARGET]);
11891 bool isTargetOffScreenBmp;
11892
11893
2/2
✓ Branch 0 taken 6478149 times.
✓ Branch 1 taken 116692259 times.
123170408 if(!bmp)
11894 {
11895 116692259 bmp = targetBitmap;
11896 116692259 isTargetOffScreenBmp = false;
11897 116692259 }
11898 else
11899 {
11900 // Render target was set to a internal bitmap (but not the screen bitmap).
11901 6478149 isTargetOffScreenBmp = true;
11902 6478149 draw_origin = DrawOrigin::Screen;
11903 }
11904
11905 123170408 current_target_bmp = bmp;
11906
11907 int xoffset, yoffset;
11908
1/2
✓ Branch 0 taken 123170408 times.
✗ Branch 1 not taken.
123170408 if (auto r = get_draw_origin_offset(draw_origin, command.draw_origin_target, xoff, yoff))
11909 {
11910 123170408 std::tie(xoffset, yoffset) = *r;
11911 123170408 }
11912 else
11913 {
11914 continue;
11915 }
11916
11917 123170408 secondary_draw_origin_xoff = 0;
11918 123170408 secondary_draw_origin_yoff = 0;
11919
2/2
✓ Branch 0 taken 121375182 times.
✓ Branch 1 taken 1795226 times.
123170408 if (command.secondary_draw_origin != DrawOrigin::Default)
11920 {
11921
1/2
✓ Branch 0 taken 1795226 times.
✗ Branch 1 not taken.
1795226 if (auto r = get_draw_origin_offset(command.secondary_draw_origin, command.secondary_draw_origin_target, xoff, yoff))
11922 {
11923 1795226 std::tie(secondary_draw_origin_xoff, secondary_draw_origin_yoff) = *r;
11924 1795226 }
11925 else
11926 {
11927 continue;
11928 }
11929 1795226 }
11930
11931
40/87
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3343769 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1170681 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1850 times.
✓ Branch 7 taken 2351475 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 404879 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 2302534 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2761640 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5327982 times.
✓ Branch 19 taken 30255774 times.
✓ Branch 20 taken 964027 times.
✓ Branch 21 taken 176452 times.
✓ Branch 22 taken 1607511 times.
✓ Branch 23 taken 201739 times.
✓ Branch 24 taken 9266 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1080 times.
✓ Branch 29 taken 936403 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 4370235 times.
✓ Branch 32 taken 50406 times.
✓ Branch 33 taken 12431 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 192290 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 502 times.
✓ Branch 38 taken 144 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 80910 times.
✓ Branch 41 taken 64994 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 11288 times.
✗ Branch 44 not taken.
✓ Branch 45 taken 1982263 times.
✓ Branch 46 taken 40175665 times.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 865 times.
✓ Branch 50 taken 45504 times.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✓ Branch 56 taken 143658 times.
✓ Branch 57 taken 2740 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✓ Branch 60 taken 1024 times.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✓ Branch 63 taken 2062708 times.
✗ Branch 64 not taken.
✓ Branch 65 taken 113653 times.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✓ Branch 72 taken 2134433 times.
✓ Branch 73 taken 34749 times.
✓ Branch 74 taken 43007 times.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✓ Branch 80 taken 19821648 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 7323 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 906 times.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
123170408 switch(sdci[0])
11932 {
11933 case RECTR:
11934 {
11935 3343769 do_rectr(bmp, sdci, xoffset, yoffset);
11936 }
11937 3343769 break;
11938 case FRAMER:
11939 {
11940 do_framer(bmp, sdci, xoffset, yoffset);
11941 }
11942 break;
11943
11944
11945 case CIRCLER:
11946 {
11947 1170681 do_circler(bmp, sdci, xoffset, yoffset);
11948 }
11949 1170681 break;
11950
11951 case ARCR:
11952 {
11953 do_arcr(bmp, sdci, xoffset, yoffset);
11954 }
11955 break;
11956
11957 case ELLIPSER:
11958 {
11959 1850 do_ellipser(bmp, sdci, xoffset, yoffset);
11960 }
11961 1850 break;
11962
11963 case LINER:
11964 {
11965 2351475 do_liner(bmp, sdci, xoffset, yoffset);
11966 }
11967 2351475 break;
11968
11969 case SPLINER:
11970 {
11971 do_spliner(bmp, sdci, xoffset, yoffset);
11972 }
11973 break;
11974
11975 case PUTPIXELR:
11976 {
11977 404879 do_putpixelr(bmp, sdci, xoffset, yoffset);
11978 }
11979 404879 break;
11980 case PIXELARRAYR:
11981 {
11982 do_putpixelsr(bmp, i, sdci, xoffset, yoffset);
11983 }
11984 break;
11985
11986 case TILEARRAYR:
11987 {
11988 do_fasttilesr(bmp, i, sdci, xoffset, yoffset);
11989 }
11990 break;
11991
11992 case LINESARRAY:
11993 {
11994 do_linesr(bmp, i, sdci, xoffset, yoffset);
11995 }
11996 break;
11997
11998 case COMBOARRAYR:
11999 {
12000 do_fastcombosr(bmp, i, sdci, xoffset, yoffset);
12001 }
12002 break;
12003
12004
12005
12006 case DRAWTILER:
12007 {
12008 2302534 do_drawtiler(bmp, sdci, xoffset, yoffset);
12009 }
12010 2302534 break;
12011
12012 case DRAWTILECLOAKEDR:
12013 {
12014 do_drawtilecloakedr(bmp, sdci, xoffset, yoffset);
12015 }
12016 break;
12017
12018 case DRAWCOMBOR:
12019 {
12020 2761640 do_drawcombor(bmp, sdci, xoffset, yoffset);
12021 }
12022 2761640 break;
12023
12024 case DRAWCOMBOCLOAKEDR:
12025 {
12026 do_drawcombocloakedr(bmp, sdci, xoffset, yoffset);
12027 }
12028 break;
12029
12030 case FASTTILER:
12031 {
12032 5327982 do_fasttiler(bmp, sdci, xoffset, yoffset);
12033 }
12034 5327982 break;
12035
12036 case FASTCOMBOR:
12037 {
12038 30255774 do_fastcombor(bmp, sdci, xoffset, yoffset);
12039 }
12040 30255774 break;
12041
12042 case DRAWCHARR:
12043 {
12044 964027 do_drawcharr(bmp, sdci, xoffset, yoffset);
12045 }
12046 964027 break;
12047
12048 case DRAWINTR:
12049 {
12050 176452 do_drawintr(bmp, sdci, xoffset, yoffset);
12051 }
12052 176452 break;
12053
12054 case DRAWSTRINGR:
12055 {
12056 1607511 do_drawstringr(bmp, i, sdci, xoffset, yoffset);
12057 }
12058 1607511 break;
12059
12060 case DRAWSTRINGR2:
12061 {
12062 201739 do_drawstringr2(bmp, i, sdci, xoffset, yoffset);
12063 }
12064 201739 break;
12065
12066 case QUADR:
12067 {
12068 9266 do_drawquadr(bmp, sdci, xoffset, yoffset);
12069 }
12070 9266 break;
12071
12072 case QUAD3DR:
12073 {
12074 do_drawquad3dr(bmp, i, sdci, xoffset, yoffset);
12075 }
12076 break;
12077
12078 case TRIANGLER:
12079 {
12080 do_drawtriangler(bmp, sdci, xoffset, yoffset);
12081 }
12082 break;
12083
12084 case TRIANGLE3DR:
12085 {
12086 do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset);
12087 }
12088 break;
12089
12090 case POLYGONR:
12091 {
12092 1080 do_polygonr(bmp, i, sdci, xoffset, yoffset);
12093 }
12094 1080 break;
12095
12096
12097 case BITMAPR:
12098 {
12099 936403 do_drawbitmapr(bmp, sdci, xoffset, yoffset);
12100 }
12101 936403 break;
12102
12103 case BITMAPEXR:
12104 {
12105 do_drawbitmapexr(bmp, sdci, xoffset, yoffset);
12106 }
12107 break;
12108
12109 case DRAWLAYERR:
12110 {
12111 4370235 do_drawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
12112 }
12113 4370235 break;
12114
12115 case DRAWSCREENR:
12116 {
12117 50406 do_drawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
12118 }
12119 50406 break;
12120
12121 12431 case BMPRECTR: bmp_do_rectr(bmp, sdci, xoffset, yoffset); break;
12122 case BMPFRAMER: bmp_do_framer(bmp, sdci, xoffset, yoffset); break;
12123 192290 case BMPCIRCLER: bmp_do_circler(bmp, sdci, xoffset, yoffset); break;
12124 case BMPARCR: bmp_do_arcr(bmp, sdci, xoffset, yoffset); break;
12125 502 case BMPELLIPSER: bmp_do_ellipser(bmp, sdci, xoffset, yoffset); break;
12126 144 case BMPLINER: bmp_do_liner(bmp, sdci, xoffset, yoffset); break;
12127 case BMPSPLINER: bmp_do_spliner(bmp, sdci, xoffset, yoffset); break;
12128 80910 case BMPPUTPIXELR: bmp_do_putpixelr(bmp, sdci, xoffset, yoffset); break;
12129 64994 case BMPDRAWTILER: bmp_do_drawtiler(bmp, sdci, xoffset, yoffset); break;
12130 case BMPDRAWTILECLOAKEDR: bmp_do_drawtilecloakedr(bmp, sdci, xoffset, yoffset); break;
12131 11288 case BMPDRAWCOMBOR: bmp_do_drawcombor(bmp, sdci, xoffset, yoffset); break;
12132 case BMPDRAWCOMBOCLOAKEDR: bmp_do_drawcombocloakedr(bmp, sdci, xoffset, yoffset); break;
12133 1982263 case BMPFASTTILER: bmp_do_fasttiler(bmp, sdci, xoffset, yoffset); break;
12134 40175665 case BMPFASTCOMBOR: bmp_do_fastcombor(bmp, sdci, xoffset, yoffset); break;
12135 case BMPDRAWCHARR: bmp_do_drawcharr(bmp, sdci, xoffset, yoffset); break;
12136 case BMPDRAWINTR: bmp_do_drawintr(bmp, sdci, xoffset, yoffset); break;
12137 865 case BMPDRAWSTRINGR: bmp_do_drawstringr(bmp, i, sdci, xoffset, yoffset); break;
12138 45504 case BMPDRAWSTRINGR2: bmp_do_drawstringr2(bmp, i, sdci, xoffset, yoffset); break;
12139 case BMPQUADR: bmp_do_drawquadr(bmp, sdci, xoffset, yoffset); break;
12140 case BMPQUAD3DR: bmp_do_drawquad3dr(bmp, i, sdci, xoffset, yoffset); break;
12141 case BMPTRIANGLER: bmp_do_drawtriangler(bmp, sdci, xoffset, yoffset); break;
12142 case BMPTRIANGLE3DR: bmp_do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset); break;
12143 case BMPPOLYGONR: bmp_do_polygonr(bmp, i, sdci, xoffset, yoffset); break;
12144 143658 case BMPDRAWLAYERR: do_bmpdrawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12145 2740 case BMPDRAWSCREENR: do_bmpdrawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12146 case BMPDRAWSCREENSOLIDR: do_bmpdrawscreen_solidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12147 case BMPDRAWSCREENSOLID2R: do_bmpdrawscreen_solidr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12148 1024 case BMPDRAWSCREENCOMBOFR: do_bmpdrawscreen_cflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12149 case BMPDRAWSCREENCOMBOIR: do_bmpdrawscreen_ciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12150 case BMPDRAWSCREENCOMBOTR: do_bmpdrawscreen_ctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12151 2062708 case BMPBLIT: bmp_do_drawbitmapexr(bmp, sdci, xoffset, yoffset); break;
12152 case BMPMODE7: bmp_do_mode7r(bmp, sdci, xoffset, yoffset); break;
12153 113653 case BMPBLITTO: bmp_do_blittor(bmp, sdci, xoffset, yoffset); break;
12154 case TILEBLIT: do_tileblit(bmp, sdci, xoffset, yoffset, false, "TileBlit()"); break;
12155 case COMBOBLIT: do_comboblit(bmp, sdci, xoffset, yoffset, false); break;
12156 case BMPTILEBLIT: do_tileblit(bmp, sdci, xoffset, yoffset, true, "TileBlit()"); break;
12157 case BMPCOMBOBLIT: do_comboblit(bmp, sdci, xoffset, yoffset, true); break;
12158 case READBITMAP: bmp_do_readr(bmp, i, sdci, xoffset, yoffset); break;
12159 case WRITEBITMAP: bmp_do_writer(bmp, i, sdci, xoffset, yoffset); break;
12160 2134433 case CLEARBITMAP: bmp_do_clearr(bmp, sdci, xoffset, yoffset); break;
12161 34749 case BITMAPCLEARTOCOLOR: bmp_do_clearcolorr(bmp, sdci, xoffset, yoffset); break;
12162 43007 case REGENERATEBITMAP: bmp_do_regenr(bmp, sdci, xoffset, yoffset); break;
12163
12164 case BMPDRAWLAYERSOLIDR: do_bmpdrawlayersolidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12165 case BMPDRAWLAYERCFLAGR: do_bmpdrawlayercflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12166 case BMPDRAWLAYERCTYPER: do_bmpdrawlayerctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12167 case BMPDRAWLAYERCIFLAGR: do_bmpdrawlayerciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12168 case BMPDRAWLAYERSOLIDITYR: do_bmpdrawlayersolidityr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12169 19821648 case BMPWRITETILE: do_bmpwritetile(bmp, sdci, xoffset, yoffset); break;
12170 case BMPDITHER: do_bmpdither(bmp, sdci, xoffset, yoffset); break;
12171 7323 case BMPREPLCOLOR: do_bmpreplcol(bmp, sdci, xoffset, yoffset); break;
12172 case BMPSHIFTCOLOR: do_bmpshiftcol(bmp, sdci, xoffset, yoffset); break;
12173 906 case BMPMASKDRAW: do_bmpmaskdraw(bmp, sdci, xoffset, yoffset); break;
12174 case BMPMASKBLIT: do_bmpmaskblit(bmp, sdci, xoffset, yoffset); break;
12175
12176 // The following are special cases, in that the target bitmap is fixed (darkscr_bmp).
12177
12178 case DRAWLIGHT_CONE:
12179 {
12180 int32_t cx = sdci[2]/10000 + xoffset;
12181 int32_t cy = sdci[3]/10000 + yoffset;
12182 int32_t dir = sdci[4]/10000;
12183 int32_t length = sdci[5];
12184 int32_t transp_rad = sdci[6];
12185 int32_t dith_rad = sdci[7];
12186 int32_t dith_type = sdci[8];
12187 int32_t dith_arg = sdci[9];
12188
12189 if(length >= 0) length /= 10000;
12190 else length = game->get_light_rad()*2;
12191 if(!length) break;
12192 if(dir < 0) break;
12193 else dir = NORMAL_DIR(dir);
12194 if(transp_rad >= 0) transp_rad /= 10000;
12195 if(dith_rad >= 0) dith_rad /= 10000;
12196 if(dith_type >= 0) dith_type /= 10000;
12197 if(dith_arg >= 0) dith_arg /= 10000;
12198
12199 // Undo the inherit offset applied within the function. xoffset/yoffset handles for us here.
12200 cx += viewport.x;
12201 cy += viewport.y;
12202
12203 doDarkroomCone(cx,cy,length,dir,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12204 }
12205 break;
12206
12207 case DRAWLIGHT_CIRCLE:
12208 case DRAWLIGHT_SQUARE:
12209 {
12210 int32_t cx = sdci[2]/10000 + xoffset;
12211 int32_t cy = sdci[3]/10000 + yoffset;
12212 int32_t radius = sdci[4];
12213 int32_t transp_rad = sdci[5];
12214 int32_t dith_rad = sdci[6];
12215 int32_t dith_type = sdci[7];
12216 int32_t dith_arg = sdci[8];
12217
12218 if(radius >= 0) radius /= 10000;
12219 else radius = game->get_light_rad();
12220 if(!radius) break;
12221 if(transp_rad >= 0) transp_rad /= 10000;
12222 if(dith_rad >= 0) dith_rad /= 10000;
12223 if(dith_type >= 0) dith_type /= 10000;
12224 if(dith_arg >= 0) dith_arg /= 10000;
12225
12226 // Undo the inherit offset applied within the function. xoffset/yoffset handles for us here.
12227 cx += viewport.x;
12228 cy += viewport.y;
12229
12230 if (sdci[0] == DRAWLIGHT_CIRCLE)
12231 doDarkroomCircle(cx,cy,radius,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12232 else
12233 doDarkroomSquare(cx,cy,radius,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12234 }
12235 break;
12236 }
12237 123170408 }
12238
12239
12240 4855801 color_map=&trans_table;
12241 418724884 }
12242
12243 16865524 void CScriptDrawingCommands::Clear()
12244 {
12245 16865524 scb.update();
12246 16865524 dirty_layers.clear();
12247
2/2
✓ Branch 0 taken 11517151 times.
✓ Branch 1 taken 5348373 times.
16865524 if(commands.empty())
12248 11517151 return;
12249
12250 //only clear what was used.
12251 5348373 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
12252 5348373 count = 0;
12253
12254 5348373 draw_container.Clear();
12255 16865524 }
12256 CScriptDrawingCommands* CScriptDrawingCommands::pop_commands()
12257 {
12258 CScriptDrawingCommands* ret = new CScriptDrawingCommands();
12259 if(commands.empty())
12260 return ret;
12261 ret->push_commands(this, false);
12262
12263 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
12264 count = 0;
12265
12266 draw_container.Clear();
12267 return ret;
12268 }
12269 void CScriptDrawingCommands::push_commands(CScriptDrawingCommands* other, bool del)
12270 {
12271 commands.insert(commands.end(), other->commands.begin(), other->commands.end());
12272 count += other->count;
12273 if(del) delete other;
12274 }
12275
12276 vector<int> CScriptDrawingCommands::get_dirty_layers_in_range(int min, int max)
12277 {
12278 vector<int> ret;
12279 for(int layer : dirty_layers)
12280 {
12281 if(layer < min) continue;
12282 if(layer > max) break;
12283 ret.push_back(layer);
12284 }
12285 return ret;
12286 }
12287
12288 170309 void do_script_draws(BITMAP *targetBitmap, mapscr* scr, int32_t xoff, int32_t yoff, bool hideLayer7)
12289 {
12290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170309 times.
170309 if(get_qr(qr_CLASSIC_DRAWING_ORDER))
12291
2/2
✓ Branch 0 taken 168799 times.
✓ Branch 1 taken 1510 times.
171819 if(XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12292 1510 do_primitives(targetBitmap, 2, xoff, yoff);
12293
2/2
✓ Branch 0 taken 163098 times.
✓ Branch 1 taken 7211 times.
170309 if(XOR(scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG))
12294 7211 do_primitives(targetBitmap, 3, xoff, yoff);
12295
1/2
✓ Branch 0 taken 170309 times.
✗ Branch 1 not taken.
170309 if(!get_qr(qr_CLASSIC_DRAWING_ORDER))
12296 if(XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12297 do_primitives(targetBitmap, 2, xoff, yoff);
12298 170309 do_primitives(targetBitmap, 0, xoff, yoff);
12299 170309 do_primitives(targetBitmap, 1, xoff, yoff);
12300
2/2
✓ Branch 0 taken 1510 times.
✓ Branch 1 taken 168799 times.
170309 if(!XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12301 168799 do_primitives(targetBitmap, 2, xoff, yoff);
12302
2/2
✓ Branch 0 taken 7211 times.
✓ Branch 1 taken 163098 times.
170309 if(!XOR(scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG))
12303 163098 do_primitives(targetBitmap, 3, xoff, yoff);
12304 170309 do_primitives(targetBitmap, 4, xoff, yoff);
12305 170309 do_primitives(targetBitmap, 5, xoff, yoff);
12306 170309 do_primitives(targetBitmap, 6, xoff, yoff);
12307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170309 times.
170309 if(!hideLayer7) do_primitives(targetBitmap, 7, xoff, yoff);
12308 170309 }
12309